diff options
| -rw-r--r-- | src/lib/core/utils.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/lib/core/utils.c b/src/lib/core/utils.c index 047fa16..deeca91 100644 --- a/src/lib/core/utils.c +++ b/src/lib/core/utils.c @@ -671,12 +671,15 @@ int xml_pretty_print_in_place(const char *filename, const char *pretty_print_pro */ int fix_tox_conf(const char *filename, char **result, size_t maxlen) { struct INIFILE *toxini; - FILE *fptemp; + FILE *fptemp = NULL; // Create new temporary tox configuration file char *tempfile = xmkstemp(&fptemp, "w+"); if (!tempfile) { SYSERROR("%s", "unable to create temporary file"); + if (fptemp) { + fclose(fptemp); + } return -1; } @@ -685,6 +688,9 @@ int fix_tox_conf(const char *filename, char **result, size_t maxlen) { *result = calloc(maxlen, sizeof(**result)); if (!*result) { guard_free(tempfile); + if (fptemp) { + fclose(fptemp); + } return -1; } } @@ -722,6 +728,7 @@ int fix_tox_conf(const char *filename, char **result, size_t maxlen) { strlen(value) + strlen(with_posargs) + 1); guard_free(*result); guard_free(tempfile); + fclose(fptemp); return -1; } value = tmp; |
