]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
blob: Avoid zero sized memcpy().
authorAndre Noll <maan@systemlinux.org>
Sun, 10 Mar 2013 14:53:05 +0000 (15:53 +0100)
committerAndre Noll <maan@systemlinux.org>
Mon, 1 Apr 2013 02:19:28 +0000 (02:19 +0000)
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

diff --git a/blob.c b/blob.c
index 50921bd4da5796d2acfa34c00a8d724c576bb67a..50fae99df80881493c9690e21107ed8826d322fb 100644 (file)
--- 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);