From: Andre Noll Date: Sun, 10 Mar 2013 14:53:05 +0000 (+0100) Subject: blob: Avoid zero sized memcpy(). X-Git-Tag: v0.5.0~10^2~6 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=6ca50bc4766fab54698a6c86b5395a49221c3408 blob: Avoid zero sized memcpy(). Calling memcpy() with a size argument of zero is a noop on Linux, so this should be OK. However, memcpy(3) does not say anything about this case, so let's be conservative here and call it only if there is anything to copy. --- diff --git a/blob.c b/blob.c index 50921bd4..50fae99d 100644 --- a/blob.c +++ b/blob.c @@ -449,7 +449,9 @@ static int stdin_command(struct command_context *cc, struct osl_object *arg_obj, query.size = arg_obj->size + stdin_obj.size; query.data = para_malloc(query.size); memcpy(query.data, arg_obj->data, arg_obj->size); - memcpy((char *)query.data + arg_obj->size, stdin_obj.data, stdin_obj.size); + if (stdin_obj.size > 0) + memcpy((char *)query.data + arg_obj->size, stdin_obj.data, + stdin_obj.size); free(stdin_obj.data); ret = send_callback_request(f, &query, result_handler, private_result_data); free(query.data);