summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2019-04-22 23:06:22 (GMT)
committerYann Collet <cyan@fb.com>2019-04-22 23:06:22 (GMT)
commit35b83a921f8030ee9b71cbb7324dc7aafaeb9878 (patch)
tree5ea898b56cfc62cdd42ad6f0c39a826995ed456e /programs
parent5a50247d5feb0b25d1869ab72bd8f6834e0d4585 (diff)
downloadlz4-35b83a921f8030ee9b71cbb7324dc7aafaeb9878.zip
lz4-35b83a921f8030ee9b71cbb7324dc7aafaeb9878.tar.gz
lz4-35b83a921f8030ee9b71cbb7324dc7aafaeb9878.tar.bz2
fix: no leak when LZ4F_dctx creation fails
strange, because it previous implementation, it would `exit()`, so it should not matter ...
Diffstat (limited to 'programs')
-rw-r--r--programs/lz4io.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/programs/lz4io.c b/programs/lz4io.c
index 105718d..960c451 100644
--- a/programs/lz4io.c
+++ b/programs/lz4io.c
@@ -1286,11 +1286,6 @@ typedef struct {
#define LZ4IO_INIT_CFILEINFO { LZ4F_INIT_FRAMEINFO, NULL, 0ULL }
-#define CHECK_Z_THROW(f) { \
- LZ4F_errorCode_t const ec = (f); \
- if (LZ4F_isError(ec)) \
- EXM_THROW(1, "LZ4F error : %s", LZ4F_getErrorName(ec)); \
-}
typedef enum { LZ4IO_LZ4F_OK, LZ4IO_format_not_known, LZ4IO_not_a_file } LZ4IO_infoResult;
@@ -1341,10 +1336,10 @@ LZ4IO_getCompressedFileInfo(LZ4IO_cFileInfo_t* cfinfo, const char* input_filenam
if (readSize > 0) {
LZ4F_dctx* dctx;
- CHECK_Z_THROW(LZ4F_createDecompressionContext(&dctx, LZ4F_VERSION));
- if (!LZ4F_isError(LZ4F_getFrameInfo(dctx, &cfinfo->frameInfo, buffer, &readSize))) {
- result = LZ4IO_LZ4F_OK;
- }
+ if (!LZ4F_isError(LZ4F_createDecompressionContext(&dctx, LZ4F_VERSION))) {
+ if (!LZ4F_isError(LZ4F_getFrameInfo(dctx, &cfinfo->frameInfo, buffer, &readSize))) {
+ result = LZ4IO_LZ4F_OK;
+ } }
LZ4F_freeDecompressionContext(dctx);
}