Skip to content

Commit

Permalink
Fix possible memory leak in Settings.c
Browse files Browse the repository at this point in the history
  • Loading branch information
peter15914 authored and BenBE committed Jan 4, 2025
1 parent 1f24250 commit 8990cc5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,15 @@ int Settings_write(const Settings* this, bool onCrash) {
xAsprintf(&tmpFilename, "%s.tmp.XXXXXX", this->filename);
int fdtmp = mkstemp(tmpFilename);
umask(cur_umask);
if (fdtmp == -1)
if (fdtmp == -1) {
free(tmpFilename);
return -errno;
}
fp = fdopen(fdtmp, "w");
if (!fp)
if (!fp) {
free(tmpFilename);
return -errno;
}
separator = '\n';
of = fprintf;
}
Expand Down

0 comments on commit 8990cc5

Please sign in to comment.