From 8d7e12b00f83c008b543c5fcd8c99bf711186e95 Mon Sep 17 00:00:00 2001 From: John Ellson Date: Tue, 6 Jan 2015 18:39:59 -0500 Subject: [PATCH] coverity #82684 --- tclpkg/gdtclft/gdtclft.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tclpkg/gdtclft/gdtclft.c b/tclpkg/gdtclft/gdtclft.c index 5a245afe9..4d99bcd7e 100644 --- a/tclpkg/gdtclft/gdtclft.c +++ b/tclpkg/gdtclft/gdtclft.c @@ -458,10 +458,10 @@ tclGdCreateCmd(Tcl_Interp * interp, int argc, Tcl_Obj * CONST objv[]) /* Not a channel, or Tcl_GetOpenFile() not supported. * See if we can open directly. */ - fileByName++; if ((filePtr = fopen(arg2, "rb")) == NULL) { return TCL_ERROR; } + fileByName++; Tcl_ResetResult(interp); } @@ -492,6 +492,9 @@ tclGdCreateCmd(Tcl_Interp * interp, int argc, Tcl_Obj * CONST objv[]) #endif } else { Tcl_AppendResult(interp, cmd + 10, "unrecognizable format requested", NULL); + if (fileByName) { + fclose(filePtr); + } return TCL_ERROR; } if (fileByName) { -- 2.40.0