write.c: handle empty buffers in write_wim_resource_from_buffer()
authorEric Biggers <ebiggers3@gmail.com>
Sat, 30 May 2015 20:48:06 +0000 (15:48 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Tue, 2 Jun 2015 02:57:49 +0000 (21:57 -0500)
src/write.c

index d0ede8b..5bd8db9 100644 (file)
@@ -1747,6 +1747,13 @@ write_wim_resource_from_buffer(const void *buf,
        int ret;
        struct blob_descriptor blob;
 
+       if (unlikely(buf_size == 0)) {
+               zero_reshdr(out_reshdr);
+               if (hash_ret)
+                       copy_hash(hash_ret, zero_hash);
+               return 0;
+       }
+
        blob_set_is_located_in_attached_buffer(&blob, (void *)buf, buf_size);
        sha1_buffer(buf, buf_size, blob.hash);
        blob.unhashed = 0;