GraphicsMagick: tiff/libtiff/tif_dir.c: Apply Su Laus leak fix f...

GraphicsMagick Commits <[email protected]> Thu, 25 Jan 2024 17:55:50 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.1641.1706226959.1744.graphicsmagick-commit@lists.sourceforge.net>
changeset c0fd9dfb800c in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=c0fd9dfb800c
summary: tiff/libtiff/tif_dir.c: Apply Su Laus leak fix from: https://gitlab.com/libtiff/libtiff/-/commit/376916d25f39bab69a3ed16963fd3f186870942c

diffstat:

 ChangeLog                                  |  5 +++++
 tiff/doc/functions/TIFFCustomDirectory.rst |  5 +++++
 tiff/libtiff/tif_dir.c                     |  4 ++++
 3 files changed, 14 insertions(+), 0 deletions(-)

diffs (48 lines):

diff -r 5ad1a75f144f -r c0fd9dfb800c ChangeLog
--- a/ChangeLog	Fri Jan 26 00:40:25 2024 +0100
+++ b/ChangeLog	Fri Jan 26 00:55:21 2024 +0100
@@ -1,3 +1,8 @@
+2024-01-26  Fojtik Jaroslav  <[email protected]>
+
+	tiff/libtiff/tif_dir.c: Apply Su Laus leak fix from:
+	https://gitlab.com/libtiff/libtiff/-/commit/376916d25f39bab69a3ed16963fd3f186870942c
+
 2024-01-26  Fojtik Jaroslav  <[email protected]>
 
 	coders/tiff.c: Refactor types to magick_uint16_t and
diff -r 5ad1a75f144f -r c0fd9dfb800c tiff/doc/functions/TIFFCustomDirectory.rst
--- a/tiff/doc/functions/TIFFCustomDirectory.rst	Fri Jan 26 00:40:25 2024 +0100
+++ b/tiff/doc/functions/TIFFCustomDirectory.rst	Fri Jan 26 00:55:21 2024 +0100
@@ -94,6 +94,11 @@
 the creation and reading of EXIF, GPS and custom directories.
 See test/custom_dir.c and test/custom_dir_EXIF_231.c
 
+After ``libtiff`` version 4.6.0 :c:func:`TIFFCreateCustomDirectory`,
+:c:func:`TIFFCreateEXIFDirectory` and :c:func:`TIFFCreateGPSDirectory` also
+releases the directory part of the `tif` structure by calling :c:func:`TIFFFreeDirectory`,
+which should have been called by the user application before creating a new directory.
+
 Hints and detailed instructions
 -------------------------------
 
diff -r 5ad1a75f144f -r c0fd9dfb800c tiff/libtiff/tif_dir.c
--- a/tiff/libtiff/tif_dir.c	Fri Jan 26 00:40:25 2024 +0100
+++ b/tiff/libtiff/tif_dir.c	Fri Jan 26 00:55:21 2024 +0100
@@ -1679,6 +1679,8 @@
  */
 int TIFFCreateDirectory(TIFF *tif)
 {
+    /* Free previously allocated memory and setup default values. */
+    TIFFFreeDirectory(tif);
     TIFFDefaultDirectory(tif);
     tif->tif_diroff = 0;
     tif->tif_nextdiroff = 0;
@@ -1691,6 +1693,8 @@
 
 int TIFFCreateCustomDirectory(TIFF *tif, const TIFFFieldArray *infoarray)
 {
+   /* Free previously allocated memory and setup default values. */
+    TIFFFreeDirectory(tif);
     TIFFDefaultDirectory(tif);
 
     /*