Return error code if output buffer is full in aec_buffer_encode().
authorMathis Rosenhauer <rosenhauer@dkrz.de>
Tue, 29 Jul 2014 07:40:33 +0000 (09:40 +0200)
committerMathis Rosenhauer <rosenhauer@dkrz.de>
Tue, 29 Jul 2014 07:40:45 +0000 (09:40 +0200)
src/encode.c
src/sz_compat.c
src/szlib.h

index 6cbc766..10788ed 100644 (file)
@@ -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;
index 91ccad7..68a75b2 100644 (file)
@@ -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,
index a448754..4e246fe 100644 (file)
@@ -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