]> wimlib.net Git - wimlib/blobdiff - src/write.c
write.c: handle empty buffers in write_wim_resource_from_buffer()
[wimlib] / src / write.c
index d0ede8bb9a42b6d87d964384254e04930f27c8c3..5bd8db911e1e275b40f5cd236d760fadf395674e 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;