From 6ca50bc4766fab54698a6c86b5395a49221c3408 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 10 Mar 2013 15:53:05 +0100 Subject: [PATCH] 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. --- blob.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 2.39.5