From 9ca5c20853d3be06378fb985aa75c75df280d1e2 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Tue, 19 Aug 2014 21:04:39 -0500 Subject: [PATCH] wimlib_create_{de,}compressor(): Check ctype first --- src/compress.c | 6 +++--- src/decompress.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compress.c b/src/compress.c index 4c99dab1..efbd2085 100644 --- a/src/compress.c +++ b/src/compress.c @@ -111,15 +111,15 @@ wimlib_create_compressor(enum wimlib_compression_type ctype, { struct wimlib_compressor *c; + if (!compressor_ctype_valid(ctype)) + return WIMLIB_ERR_INVALID_COMPRESSION_TYPE; + if (c_ret == NULL) return WIMLIB_ERR_INVALID_PARAM; if (max_block_size == 0) return WIMLIB_ERR_INVALID_PARAM; - if (!compressor_ctype_valid(ctype)) - return WIMLIB_ERR_INVALID_COMPRESSION_TYPE; - c = MALLOC(sizeof(*c)); if (c == NULL) return WIMLIB_ERR_NOMEM; diff --git a/src/decompress.c b/src/decompress.c index 4ebd940d..b8ed8dfc 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -59,15 +59,15 @@ wimlib_create_decompressor(enum wimlib_compression_type ctype, { struct wimlib_decompressor *dec; + if (!decompressor_ctype_valid(ctype)) + return WIMLIB_ERR_INVALID_COMPRESSION_TYPE; + if (dec_ret == NULL) return WIMLIB_ERR_INVALID_PARAM; if (max_block_size == 0) return WIMLIB_ERR_INVALID_PARAM; - if (!decompressor_ctype_valid(ctype)) - return WIMLIB_ERR_INVALID_COMPRESSION_TYPE; - dec = MALLOC(sizeof(*dec)); if (dec == NULL) return WIMLIB_ERR_NOMEM; -- 2.43.0