aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-23 10:40:52 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2016-01-23 10:40:52 +0100
commit8ddb6805a9d0c611f81033c038b0a4773a4c494e (patch)
tree926e9ba467fcb9382ba461c80688ff4519f72931
parent3a9befb516ca6dcffc826fd3c9af14fd51fdf4dc (diff)
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
-rw-r--r--gtp/gtp.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/gtp/gtp.c b/gtp/gtp.c
index a3772ff..be53b5e 100644
--- a/gtp/gtp.c
+++ b/gtp/gtp.c
@@ -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));