Skip to content

Commit 2a0350f

Browse files
committed
unixpwd.c: fix error path file descriptor leak
Fixes a warning reported by codechecker Signed-off-by: Edwin Török <[email protected]>
1 parent 6ee60f1 commit 2a0350f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

unixpwd/c/unixpwd.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ unixpwd_setspw(const char *user, char *password)
144144
*sp;
145145
char buf[BUFLEN];
146146
int tmp;
147-
FILE *tmp_file;
147+
FILE *tmp_file = NULL;
148148
char tmp_name[PATH_MAX];
149149
struct stat statbuf;
150150
int rc;
@@ -164,6 +164,8 @@ unixpwd_setspw(const char *user, char *password)
164164
return rc;
165165
}
166166
if (lckpwdf() != 0) {
167+
if (tmp_file)
168+
fclose(tmp_file);
167169
close(tmp);
168170
unlink(tmp_name);
169171
return ENOLCK;

0 commit comments

Comments
 (0)