summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/libtiff/libtiff/tif_zstd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/libtiff/libtiff/tif_zstd.c')
-rw-r--r--src/3rdparty/libtiff/libtiff/tif_zstd.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/3rdparty/libtiff/libtiff/tif_zstd.c b/src/3rdparty/libtiff/libtiff/tif_zstd.c
index 14ac081..960aa90 100644
--- a/src/3rdparty/libtiff/libtiff/tif_zstd.c
+++ b/src/3rdparty/libtiff/libtiff/tif_zstd.c
@@ -101,18 +101,16 @@ ZSTDPreDecode(TIFF* tif, uint16_t s)
if( (sp->state & LSTATE_INIT_DECODE) == 0 )
tif->tif_setupdecode(tif);
- if( sp->dstream )
+ if( sp->dstream == NULL )
{
- ZSTD_freeDStream(sp->dstream);
- sp->dstream = NULL;
+ sp->dstream = ZSTD_createDStream();
+ if( sp->dstream == NULL ) {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Cannot allocate decompression stream");
+ return 0;
+ }
}
- sp->dstream = ZSTD_createDStream();
- if( sp->dstream == NULL ) {
- TIFFErrorExt(tif->tif_clientdata, module,
- "Cannot allocate decompression stream");
- return 0;
- }
zstd_ret = ZSTD_initDStream(sp->dstream);
if( ZSTD_isError(zstd_ret) ) {
TIFFErrorExt(tif->tif_clientdata, module,
@@ -203,15 +201,13 @@ ZSTDPreEncode(TIFF* tif, uint16_t s)
if( sp->state != LSTATE_INIT_ENCODE )
tif->tif_setupencode(tif);
- if (sp->cstream) {
- ZSTD_freeCStream(sp->cstream);
- sp->cstream = NULL;
- }
- sp->cstream = ZSTD_createCStream();
- if( sp->cstream == NULL ) {
- TIFFErrorExt(tif->tif_clientdata, module,
- "Cannot allocate compression stream");
- return 0;
+ if (sp->cstream == NULL) {
+ sp->cstream = ZSTD_createCStream();
+ if( sp->cstream == NULL ) {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Cannot allocate compression stream");
+ return 0;
+ }
}
zstd_ret = ZSTD_initCStream(sp->cstream, sp->compression_level);