From b6480e872abc920f0157f8fed354a966df581c2f Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Wed, 23 Nov 2022 11:44:37 +0100
Subject: [PATCH] tiffcp: fix leak of TIFFOpenOptionsAlloc() introduced in
latest commit (master only)
Fixes Coverity CID 1517032
---
tools/tiffcp.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
index 4b9f1e77..ca20119d 100644
--- a/tools/tiffcp.c
+++ b/tools/tiffcp.c
@@ -168,7 +168,11 @@ static TIFF* openSrcImage (char **imageSpec)
**imageSpec = '\0';
tif = TIFFOpenExt (fn, mode, opts);
/* but, ignore any single trailing comma */
- if (!(*imageSpec)[1]) {*imageSpec = NULL; return tif;}
+ if (!(*imageSpec)[1]) {
+ *imageSpec = NULL;
+ TIFFOpenOptionsFree(opts);
+ return tif;
+ }
if (tif) {
**imageSpec = comma; /* replace the comma */
if (!nextSrcImage(tif, imageSpec)) {