]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
c-hyper: handle NULL from hyper_buf_copy()
authorDaniel Stenberg <daniel@haxx.se>
Fri, 28 May 2021 10:31:55 +0000 (12:31 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 28 May 2021 13:08:11 +0000 (15:08 +0200)
Closes #7143

lib/c-hyper.c

index be4618eba5fad2475d3ab71121e3ba63cf2b12e0..0f307f3e827af3e9dad7d9c9a233f5a2aa42d0a4 100644 (file)
@@ -532,8 +532,12 @@ static int uploadpostfields(void *userdata, hyper_context *ctx,
     *chunk = NULL; /* nothing more to deliver */
   else {
     /* send everything off in a single go */
-    *chunk = hyper_buf_copy(data->set.postfields,
-                            (size_t)data->req.p.http->postsize);
+    hyper_buf *copy = hyper_buf_copy(data->set.postfields,
+                                     (size_t)data->req.p.http->postsize);
+    if(copy)
+      *chunk = copy;
+    else
+      return HYPER_POLL_ERROR;
     data->req.upload_done = TRUE;
   }
   return HYPER_POLL_READY;
@@ -552,8 +556,13 @@ static int uploadstreamed(void *userdata, hyper_context *ctx,
   if(!fillcount)
     /* done! */
     *chunk = NULL;
-  else
-    *chunk = hyper_buf_copy((uint8_t *)data->state.ulbuf, fillcount);
+  else {
+    hyper_buf *copy = hyper_buf_copy((uint8_t *)data->state.ulbuf, fillcount);
+    if(copy)
+      *chunk = copy;
+    else
+      return HYPER_POLL_ERROR;
+  }
   return HYPER_POLL_READY;
 }