gtp: Do not leak the restart counter file handle in case of error

If the file exists but can not be read the file would not be closed.
Jump to a label that will close f.

Fixes: CID#57917
This commit is contained in:
Holger Hans Peter Freyther 2016-01-23 10:40:52 +01:00
parent 3a9befb516
commit 8ddb6805a9
1 changed files with 2 additions and 1 deletions

View File

@ -665,7 +665,7 @@ static void log_restart(struct gsn_t *gsn)
if (rc != 1) {
LOGP(DLGTP, LOGL_ERROR,
"fscanf failed to read counter value\n");
return;
goto close_file;
}
if (fclose(f)) {
LOGP(DLGTP, LOGL_ERROR,
@ -685,6 +685,7 @@ static void log_restart(struct gsn_t *gsn)
umask(i);
fprintf(f, "%d\n", gsn->restart_counter);
close_file:
if (fclose(f)) {
LOGP(DLGTP, LOGL_ERROR,
"fclose failed: Error = %s\n", strerror(errno));