Move LZW codec state block allocation back to TIFFInitLZW(), because its
initialization in LZWSetupDecode() cause problems with predictor initialization. Remove O_RDONLY check during state block allocation to be able open LZW compressed files in update mode. Problem exist for libtiff version of the tif_lzw.c module. One from lzw-compression-kit hasn't such troubles.
This commit is contained in:
parent
1e5a0127b9
commit
015b5e862a
@ -1,4 +1,4 @@
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_lzw.c,v 1.18 2003-07-08 16:40:46 warmerda Exp $ */
|
||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_lzw.c,v 1.19 2003-08-05 08:37:41 dron Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988-1997 Sam Leffler
|
||||
@ -190,33 +190,9 @@ static int
|
||||
LZWSetupDecode(TIFF* tif)
|
||||
{
|
||||
LZWDecodeState* sp = DecoderState(tif);
|
||||
static const char module[] = " LZWSetupDecode";
|
||||
static const char module[] = "LZWSetupDecode";
|
||||
int code;
|
||||
|
||||
if( sp == NULL )
|
||||
{
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record
|
||||
* values.
|
||||
*/
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof(LZWDecodeState));
|
||||
if (tif->tif_data == NULL)
|
||||
{
|
||||
TIFFError("LZWPreDecode", "No space for LZW state block");
|
||||
return (0);
|
||||
}
|
||||
|
||||
DecoderState(tif)->dec_codetab = NULL;
|
||||
DecoderState(tif)->dec_decode = NULL;
|
||||
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
*/
|
||||
(void) TIFFPredictorInit(tif);
|
||||
|
||||
sp = DecoderState(tif);
|
||||
}
|
||||
|
||||
assert(sp != NULL);
|
||||
|
||||
if (sp->dec_codetab == NULL) {
|
||||
@ -729,6 +705,15 @@ TIFFInitLZW(TIFF* tif, int scheme)
|
||||
{
|
||||
assert(scheme == COMPRESSION_LZW);
|
||||
|
||||
/*
|
||||
* Allocate state block so tag methods have storage to record values.
|
||||
*/
|
||||
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWDecodeState));
|
||||
if (tif->tif_data == NULL)
|
||||
goto bad;
|
||||
DecoderState(tif)->dec_codetab = NULL;
|
||||
DecoderState(tif)->dec_decode = NULL;
|
||||
|
||||
/*
|
||||
* Install codec methods.
|
||||
*/
|
||||
@ -740,7 +725,16 @@ TIFFInitLZW(TIFF* tif, int scheme)
|
||||
tif->tif_decodetile = LZWDecode;
|
||||
tif->tif_cleanup = LZWCleanup;
|
||||
|
||||
return (1);
|
||||
/*
|
||||
* Setup predictor setup.
|
||||
*/
|
||||
(void) TIFFPredictorInit(tif);
|
||||
|
||||
return (1);
|
||||
|
||||
bad:
|
||||
TIFFError("TIFFInitLZW", "No space for LZW state block");
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user