Curl_fillreadbuffer: avoid double-free trailer buf on error 32/216632/1 accepted/tizen/base/20191105.214055 submit/tizen_base/20191031.113633
authorSeonah Moon <seonah1.moon@samsung.com>
Wed, 30 Oct 2019 02:34:31 +0000 (11:34 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Wed, 30 Oct 2019 02:34:35 +0000 (11:34 +0900)
Backported Patch link:
https://github.com/curl/curl/pull/4307

Change-Id: I5b695b661cf946b74e065d1a65697e74d7ef8af6

lib/http.c

index 46ac15a..1be9c0f 100644 (file)
@@ -1095,10 +1095,14 @@ Curl_send_buffer *Curl_add_buffer_init(void)
  */
 void Curl_add_buffer_free(Curl_send_buffer **inp)
 {
-  Curl_send_buffer *in = *inp;
-  if(in) /* deal with NULL input */
+  Curl_send_buffer *in;
+  if(!inp)
+    return;
+  in = *inp;
+  if(in) { /* deal with NULL input */
     free(in->buffer);
-  free(in);
+    free(in);
+  }
   *inp = NULL;
 }