mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
fix memcpy calls with NULL and len 0 (pretty harmless, but causing compiler warnings)
This commit is contained in:
+13
-8
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user