X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Fresource.c;h=d5c26b40c00ace2b4392e8821879b22276fb7284;hb=567fe53d9dfe5b65f4f9b73f64063203c4ace293;hp=20e27e1776b55b9825fe80b110c31da181ddfa33;hpb=0ecb0529b5fcacc1abafa1f3f02a40c44783ada8;p=wimlib diff --git a/src/resource.c b/src/resource.c index 20e27e17..d5c26b40 100644 --- a/src/resource.c +++ b/src/resource.c @@ -25,6 +25,11 @@ # include "config.h" #endif +#include +#include +#include + +#include "wimlib/alloca.h" #include "wimlib/assert.h" #include "wimlib/bitops.h" #include "wimlib/endianness.h" @@ -45,13 +50,6 @@ # include "wimlib/ntfs_3g.h" #endif -#ifdef HAVE_ALLOCA_H -# include -#endif -#include -#include -#include -#include /* * Compressed WIM resources @@ -137,7 +135,6 @@ read_compressed_wim_resource(const struct wim_resource_spec * const rspec, int errno_save; u64 *chunk_offsets = NULL; - u8 *_ubuf = NULL; u8 *ubuf = NULL; void *cbuf = NULL; bool chunk_offsets_malloced = false; @@ -368,14 +365,13 @@ read_compressed_wim_resource(const struct wim_resource_spec * const rspec, /* Allocate buffer for holding the uncompressed data of each chunk. */ if (chunk_size <= STACK_MAX) { - _ubuf = alloca(chunk_size + 15); + ubuf = alloca(chunk_size); } else { - _ubuf = MALLOC(chunk_size + 15); - if (_ubuf == NULL) + ubuf = MALLOC(chunk_size); + if (ubuf == NULL) goto oom; ubuf_malloced = true; } - ubuf = (u8 *)(((uintptr_t)_ubuf + 15) & ~15); /* Allocate a temporary buffer for reading compressed chunks, each of * which can be at most @chunk_size - 1 bytes. This excludes compressed @@ -549,7 +545,7 @@ out_free_memory: if (chunk_offsets_malloced) FREE(chunk_offsets); if (ubuf_malloced) - FREE(_ubuf); + FREE(ubuf); if (cbuf_malloced) FREE(cbuf); errno = errno_save;