summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2022-09-11 12:55:15 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2022-09-17 08:33:11 -0700
commitf5cb430f246850e8213fe5cd95b4ea44228f3c3b (patch)
tree1e415cf84e7b6c37bfabc1d887c13969613850e4
parent776e7c4dae63e2541a6f3822c3e9d659f9af101e (diff)
Avoid leak of new_file if we decide not to use it
As warned by cppcheck: xditview.c:338:13: error: Resource leak: new_file [resourceLeak] return; ^ xditview.c:342:13: error: Resource leak: new_file [resourceLeak] return; ^ Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--xditview.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/xditview.c b/xditview.c
index 1a65771..31d9dd4 100644
--- a/xditview.c
+++ b/xditview.c
@@ -335,10 +335,12 @@ VisitFile (char *name, Boolean resetPage)
/* Make sure it is a regular file */
if (fstat(fileno(new_file), &stbuf) != 0) {
perror(name);
+ fclose(new_file);
return;
}
if (! S_ISREG(stbuf.st_mode)){
fprintf(stderr, "%s is not a regular file.\n", name);
+ fclose(new_file);
return;
}