LZMAPreEncode: emit verbose error if lzma_stream_encoder() fails (typically because not enough memory available)

This commit is contained in:
Even Rouault 2018-10-18 11:10:31 +02:00
parent d780c9db3f
commit 4429f75fab
No known key found for this signature in database
GPG Key ID: 33EBBFC47B3DD87D

View File

@ -247,6 +247,7 @@ LZMAPreEncode(TIFF* tif, uint16 s)
{ {
static const char module[] = "LZMAPreEncode"; static const char module[] = "LZMAPreEncode";
LZMAState *sp = EncoderState(tif); LZMAState *sp = EncoderState(tif);
lzma_ret ret;
(void) s; (void) s;
assert(sp != NULL); assert(sp != NULL);
@ -260,7 +261,13 @@ LZMAPreEncode(TIFF* tif, uint16 s)
"Liblzma cannot deal with buffers this size"); "Liblzma cannot deal with buffers this size");
return 0; return 0;
} }
return (lzma_stream_encoder(&sp->stream, sp->filters, sp->check) == LZMA_OK); ret = lzma_stream_encoder(&sp->stream, sp->filters, sp->check);
if (ret != LZMA_OK) {
TIFFErrorExt(tif->tif_clientdata, module,
"Error in lzma_stream_encoder(): %s", LZMAStrerror(ret));
return 0;
}
return 1;
} }
/* /*