]> granicus.if.org Git - graphviz/commitdiff
coverity #82684
authorJohn Ellson <ellson@research.att.com>
Tue, 6 Jan 2015 23:39:59 +0000 (18:39 -0500)
committerJohn Ellson <ellson@research.att.com>
Tue, 6 Jan 2015 23:39:59 +0000 (18:39 -0500)
tclpkg/gdtclft/gdtclft.c

index 5a245afe985ba017c318df3107ed93afdb76f130..4d99bcd7edfe5f9fd0f5384e81add87f04ed7d43 100644 (file)
@@ -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) {