Avoid calling memcpy with length 0.

Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/ad3282d9
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/ad3282d9
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/ad3282d9

Branch: refs/heads/master
Commit: ad3282d95839d840c7e4f9300754949f941cf12b
Parents: 73b2e09
Author: Marvin Humphrey <[email protected]>
Authored: Fri Jul 24 14:11:37 2015 -0700
Committer: Marvin Humphrey <[email protected]>
Committed: Thu Jul 30 10:42:10 2015 -0700

----------------------------------------------------------------------
 runtime/core/Clownfish/Blob.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ad3282d9/runtime/core/Clownfish/Blob.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Blob.c b/runtime/core/Clownfish/Blob.c
index 0766396..4d3b66b 100644
--- a/runtime/core/Clownfish/Blob.c
+++ b/runtime/core/Clownfish/Blob.c
@@ -33,7 +33,9 @@ Blob_new(const char *buf, size_t size) {
 Blob*
 Blob_init(Blob *self, const char *buf, size_t size) {
     char *copy = (char*)MALLOCATE(size);
-    memcpy(copy, buf, size);
+    if (size > 0) {
+        memcpy(copy, buf, size);
+    }
 
     self->buf      = copy;
     self->size     = size;

Reply via email to