From aa5a267eb5c57f404e138acdf40172015a9fd2a6 Mon Sep 17 00:00:00 2001 From: Mathis Rosenhauer Date: Tue, 29 Jul 2014 09:40:33 +0200 Subject: [PATCH] Return error code if output buffer is full in aec_buffer_encode(). --- src/encode.c | 4 ++-- src/sz_compat.c | 6 +----- src/szlib.h | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/encode.c b/src/encode.c index 6cbc766..10788ed 100644 --- a/src/encode.c +++ b/src/encode.c @@ -932,8 +932,8 @@ int aec_buffer_encode(struct aec_stream *strm) if (status != AEC_OK) return status; status = aec_encode(strm, AEC_FLUSH); - if (strm->avail_in > 0) - status = AEC_DATA_ERROR; + if (strm->avail_out == 0) + status = AEC_STREAM_ERROR; aec_encode_end(strm); return status; diff --git a/src/sz_compat.c b/src/sz_compat.c index 91ccad7..68a75b2 100644 --- a/src/sz_compat.c +++ b/src/sz_compat.c @@ -170,18 +170,14 @@ int SZ_BufftoBuffCompress(void *dest, size_t *destLen, } status = aec_buffer_encode(&strm); - if (status != AEC_OK) - return status; - *destLen = strm.total_out; if (pad_scanline && padbuf) free(padbuf); - if (interleave && buf) free(buf); - return SZ_OK; + return status; } int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, diff --git a/src/szlib.h b/src/szlib.h index a448754..4e246fe 100644 --- a/src/szlib.h +++ b/src/szlib.h @@ -15,7 +15,7 @@ #define SZ_NO_ENCODER_ERROR -1 #define SZ_PARAM_ERROR AEC_CONF_ERROR #define SZ_MEM_ERROR AEC_MEM_ERROR -#define SZ_OUTBUFF_FULL -2 +#define SZ_OUTBUFF_FULL AEC_STREAM_ERROR #define SZ_MAX_PIXELS_PER_BLOCK 32 #define SZ_MAX_BLOCKS_PER_SCANLINE 128 -- 2.7.4