Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unixpwd.c: fix error path file descriptor leak
Fixes a warning reported by codechecker

Signed-off-by: Edwin Török <[email protected]>
  • Loading branch information
edwintorok committed Mar 4, 2025
commit 2a0350ff0bd3c0d81a8504f86fdae07049a1c0e8
4 changes: 3 additions & 1 deletion unixpwd/c/unixpwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ unixpwd_setspw(const char *user, char *password)
*sp;
char buf[BUFLEN];
int tmp;
FILE *tmp_file;
FILE *tmp_file = NULL;
char tmp_name[PATH_MAX];
struct stat statbuf;
int rc;
Expand All @@ -164,6 +164,8 @@ unixpwd_setspw(const char *user, char *password)
return rc;
}
if (lckpwdf() != 0) {
if (tmp_file)
fclose(tmp_file);
close(tmp);
unlink(tmp_name);
return ENOLCK;
Expand Down