Add memdup() function
[wimlib] / src / security.c
index 4cd898b5b4a3fa9e0cb86d3aa6f7af224f37e9fe..192786dfd17f583ed4eb2f0c1ebd38a307428b64 100644 (file)
@@ -271,10 +271,9 @@ read_wim_security_data(const u8 metadata_resource[], size_t metadata_resource_le
                total_len += sd->sizes[i];
                if (total_len > (u64)sd->total_length)
                        goto out_invalid_sd;
-               sd->descriptors[i] = MALLOC(sd->sizes[i]);
+               sd->descriptors[i] = memdup(p, sd->sizes[i]);
                if (!sd->descriptors[i])
                        goto out_of_memory;
-               memcpy(sd->descriptors[i], p, sd->sizes[i]);
                p += sd->sizes[i];
                empty_sacl_fixup((SECURITY_DESCRIPTOR_RELATIVE*)sd->descriptors[i],
                                 &sd->sizes[i]);