summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libtiff/tif_hash_set.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libtiff/tif_hash_set.c b/libtiff/tif_hash_set.c
index 5fbfbbea..49718ce2 100644
--- a/libtiff/tif_hash_set.c
+++ b/libtiff/tif_hash_set.c
@@ -433,7 +433,8 @@ static void **TIFFHashSetFindPtr(TIFFHashSet *set, const void *elt)
* @param set the hash set
* @param elt the new element to insert in the hash set
*
- * @return true if success
+ * @return true if success. If false is returned, elt has not been inserted,
+ * but TIFFHashSetInsert() will have run the free function if provided.
*/
bool TIFFHashSetInsert(TIFFHashSet *set, void *elt)
@@ -457,6 +458,8 @@ bool TIFFHashSetInsert(TIFFHashSet *set, void *elt)
if (!TIFFHashSetRehash(set))
{
set->nIndiceAllocatedSize--;
+ if (set->fnFreeEltFunc)
+ set->fnFreeEltFunc(elt);
return false;
}
}
@@ -470,6 +473,8 @@ bool TIFFHashSetInsert(TIFFHashSet *set, void *elt)
TIFFList *new_elt = TIFFHashSetGetNewListElt(set);
if (new_elt == NULL)
{
+ if (set->fnFreeEltFunc)
+ set->fnFreeEltFunc(elt);
return false;
}
new_elt->pData = elt;