From 8990cc5b9b8873d8220170720ced58051d2d6714 Mon Sep 17 00:00:00 2001 From: peter15914 <48548636+peter15914@users.noreply.github.com> Date: Fri, 3 Jan 2025 13:28:38 +0500 Subject: [PATCH] Fix possible memory leak in Settings.c --- Settings.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Settings.c b/Settings.c index 92cd85427..bcb7fbfaa 100644 --- a/Settings.c +++ b/Settings.c @@ -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; }