Remove use of tif_dirnumber

This commit is contained in:
Even Rouault
2023-01-06 15:23:06 +01:00
parent 47591619e1
commit c074eb73d3
6 changed files with 4 additions and 18 deletions

View File

@@ -2104,7 +2104,6 @@ int TIFFSetSubDirectory(TIFF *tif, uint64_t diroff)
{
/* Reset IFD list to start new one for SubIFD chain and also start
* SubIFD chain with tif_curdir=0. */
tif->tif_dirnumber = 0;
_TIFFCleanupIFDOffsetAndNumberMaps(tif); /* invalidate IFD loop lists */
tif->tif_curdir = 0; /* first directory of new chain */
/* add this offset to new IFD list */
@@ -2233,7 +2232,6 @@ int TIFFUnlinkDirectory(TIFF *tif, tdir_t dirn)
tif->tif_row = (uint32_t)-1;
tif->tif_curstrip = (uint32_t)-1;
tif->tif_curdir = TIFF_NON_EXISTENT_DIR_NUMBER;
tif->tif_dirnumber = 0;
_TIFFCleanupIFDOffsetAndNumberMaps(tif);
return (1);
}

View File

@@ -5448,7 +5448,8 @@ int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, uint64_t diroff)
}
/* Arbitrary (hopefully big enough) limit */
if (tif->tif_dirnumber >= TIFF_MAX_DIR_COUNT)
if (TIFFHashSetSize(tif->tif_map_dir_offset_to_number) >=
TIFF_MAX_DIR_COUNT)
{
TIFFErrorExtR(tif, "_TIFFCheckDirNumberAndOffset",
"Cannot handle more than %u TIFF directories",
@@ -5481,8 +5482,6 @@ int _TIFFCheckDirNumberAndOffset(TIFF *tif, tdir_t dirn, uint64_t diroff)
return 0;
}
tif->tif_dirnumber++;
return 1;
} /* --- _TIFFCheckDirNumberAndOffset() ---*/
@@ -5497,13 +5496,6 @@ int _TIFFGetDirNumberFromOffset(TIFF *tif, uint64_t diroff, tdir_t *dirn)
{
if (diroff == 0) /* no more directories */
return 0;
if (tif->tif_dirnumber >= TIFF_MAX_DIR_COUNT)
{
TIFFErrorExtR(tif, "_TIFFGetDirNumberFromOffset",
"Cannot handle more than %u TIFF directories",
TIFF_MAX_DIR_COUNT);
return 0;
}
/* Check if offset is already in the list and return matching directory
* number. Otherwise update IFD list using TIFFNumberOfDirectories() and

View File

@@ -162,7 +162,6 @@ TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
return set;
}
#ifdef notdef
/************************************************************************/
/* TIFFHashSetSize() */
/************************************************************************/
@@ -182,7 +181,6 @@ int TIFFHashSetSize(const TIFFHashSet *set)
assert(set != NULL);
return set->nSize;
}
#endif
/************************************************************************/
/* TIFFHashSetGetNewListElt() */

View File

@@ -71,11 +71,11 @@ extern "C"
void TIFFHashSetDestroy(TIFFHashSet *set);
int TIFFHashSetSize(const TIFFHashSet *set);
#ifdef notused
void TIFFHashSetClear(TIFFHashSet *set);
int TIFFHashSetSize(const TIFFHashSet *set);
/** TIFFHashSetIterEltFunc */
typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data);

View File

@@ -485,7 +485,6 @@ TIFF *TIFFClientOpenExt(const char *name, const char *mode,
goto bad;
tif->tif_diroff = 0;
tif->tif_lastdiroff = 0;
tif->tif_dirnumber = 0;
return (tif);
}
/*

View File

@@ -148,7 +148,6 @@ struct tiff
uint64_t tif_lastdiroff; /* file offset of last directory written so far */
TIFFHashSet *tif_map_dir_offset_to_number;
TIFFHashSet *tif_map_dir_number_to_offset;
tdir_t tif_dirnumber; /* number of already seen directories */
TIFFDirectory tif_dir; /* internal rep of current directory */
TIFFDirectory
tif_customdir; /* custom IFDs are separated from the main ones */