From e5bacb710f6e1b83556d1062c9a5ad72f4bf1a8f Mon Sep 17 00:00:00 2001
From: Su_Laus <[EMAIL REDACTED]>
Date: Wed, 14 Aug 2024 21:03:04 +0200
Subject: [PATCH] Fix some Coverity Scan issues introduced by MR 634.
---
libtiff/tif_dirwrite.c | 4 ++--
test/test_directory.c | 5 +----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
index 48407a3b..0701f40d 100644
--- a/libtiff/tif_dirwrite.c
+++ b/libtiff/tif_dirwrite.c
@@ -3198,7 +3198,7 @@ static int TIFFLinkDirectory(TIFF *tif)
/*
* Not the first directory, search to the last and append.
*/
- tdir_t dirn = -1;
+ tdir_t dirn = 0;
if (tif->tif_lastdiroff != 0 &&
_TIFFGetDirNumberFromOffset(tif, tif->tif_lastdiroff, &dirn))
{
@@ -3276,7 +3276,7 @@ static int TIFFLinkDirectory(TIFF *tif)
/*
* Not the first directory, search to the last and append.
*/
- tdir_t dirn = -1;
+ tdir_t dirn = 0;
if (tif->tif_lastdiroff != 0 &&
_TIFFGetDirNumberFromOffset(tif, tif->tif_lastdiroff, &dirn))
{
diff --git a/test/test_directory.c b/test/test_directory.c
index a50096a4..e9fdda6e 100644
--- a/test/test_directory.c
+++ b/test/test_directory.c
@@ -2140,10 +2140,7 @@ int test_curdircount_setting(unsigned int openMode)
return 0;
failure:
- if (tif)
- {
- TIFFClose(tif);
- }
+ TIFFClose(tif);
return 1;
} /*-- test_curdircount_setting() --*/