gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [libmicrohttpd] branch master updated: fix memcpy calls wit


From: gnunet
Subject: [GNUnet-SVN] [libmicrohttpd] branch master updated: fix memcpy calls with NULL and len 0 (pretty harmless, but causing compiler warnings)
Date: Thu, 22 Feb 2018 18:19:05 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository libmicrohttpd.

The following commit(s) were added to refs/heads/master by this push:
     new 70212465 fix memcpy calls with NULL and len 0 (pretty harmless, but 
causing compiler warnings)
70212465 is described below

commit 7021246581ac32b6a2010bf4afd4685b54369259
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Feb 22 18:19:02 2018 +0100

    fix memcpy calls with NULL and len 0 (pretty harmless, but causing compiler 
warnings)
---
 src/examples/demo.c       | 21 +++++++++++++--------
 src/examples/demo_https.c | 17 +++++++++++------
 2 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/examples/demo.c b/src/examples/demo.c
index 6c9ad049..858fb735 100644
--- a/src/examples/demo.c
+++ b/src/examples/demo.c
@@ -433,7 +433,7 @@ struct UploadContext
  * @param ret string to update, NULL or 0-terminated
  * @param data data to append
  * @param size number of bytes in 'data'
- * @return MHD_NO on allocation failure, MHD_YES on success
+ * @return #MHD_NO on allocation failure, #MHD_YES on success
  */
 static int
 do_append (char **ret,
@@ -447,13 +447,18 @@ do_append (char **ret,
     old_len = 0;
   else
     old_len = strlen (*ret);
-  buf = malloc (old_len + size + 1);
-  if (NULL == buf)
+  if (NULL == (buf = malloc (old_len + size + 1)))
     return MHD_NO;
-  memcpy (buf, *ret, old_len);
   if (NULL != *ret)
-    free (*ret);
-  memcpy (&buf[old_len], data, size);
+    {
+      memcpy (buf,
+             *ret,
+             old_len);
+      free (*ret);
+    }
+  memcpy (&buf[old_len],
+         data,
+         size);
   buf[old_len + size] = '\0';
   *ret = buf;
   return MHD_YES;
@@ -476,8 +481,8 @@ do_append (char **ret,
  *              specified offset
  * @param off offset of data in the overall value
  * @param size number of bytes in data available
- * @return MHD_YES to continue iterating,
- *         MHD_NO to abort the iteration
+ * @return #MHD_YES to continue iterating,
+ *         #MHD_NO to abort the iteration
  */
 static int
 process_upload_data (void *cls,
diff --git a/src/examples/demo_https.c b/src/examples/demo_https.c
index 806464a2..88b01bbf 100644
--- a/src/examples/demo_https.c
+++ b/src/examples/demo_https.c
@@ -434,7 +434,7 @@ struct UploadContext
  * @param ret string to update, NULL or 0-terminated
  * @param data data to append
  * @param size number of bytes in 'data'
- * @return MHD_NO on allocation failure, MHD_YES on success
+ * @return #MHD_NO on allocation failure, #MHD_YES on success
  */
 static int
 do_append (char **ret,
@@ -448,13 +448,18 @@ do_append (char **ret,
     old_len = 0;
   else
     old_len = strlen (*ret);
-  buf = malloc (old_len + size + 1);
-  if (NULL == buf)
+  if (NULL == (buf = malloc (old_len + size + 1)))
     return MHD_NO;
-  memcpy (buf, *ret, old_len);
   if (NULL != *ret)
-    free (*ret);
-  memcpy (&buf[old_len], data, size);
+    {
+      memcpy (buf,
+             *ret,
+             old_len);
+      free (*ret);
+    }
+  memcpy (&buf[old_len],
+         data,
+         size);
   buf[old_len + size] = '\0';
   *ret = buf;
   return MHD_YES;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]