From a9cb25c5c2b9d864f77033533fab9f2f8a6f94ab Mon Sep 17 00:00:00 2001 From: Luka Perkov Date: Wed, 10 Jul 2013 01:50:48 +0200 Subject: [PATCH] close file pointer before exiting function Signed-off-by: Luka Perkov --- block.c | 4 +++- mount_root.c | 13 ++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index c9285d6..2289b77 100644 --- a/block.c +++ b/block.c @@ -545,8 +545,10 @@ static char* find_mount_point(char *block) char *p = &line[len + 1]; char *t = strstr(p, " "); - if (!t) + if (!t) { + fclose(fp); return NULL; + } *t = '\0'; point = p; break; diff --git a/mount_root.c b/mount_root.c index ede5718..8868e40 100644 --- a/mount_root.c +++ b/mount_root.c @@ -109,12 +109,16 @@ static char* find_mount(char *mp) while (fgets(line, sizeof(line), fp)) { char *s, *t = strstr(line, " "); - if (!t) + if (!t) { + fclose(fp); return NULL; + } t++; s = strstr(t, " "); - if (!s) + if (!s) { + fclose(fp); return NULL; + } *s = '\0'; if (!strcmp(t, mp)) { @@ -143,13 +147,16 @@ static char* find_mount_point(char *block, char *fs) char *p = &line[len + 1]; char *t = strstr(p, " "); - if (!t) + if (!t) { + fclose(fp); return NULL; + } *t = '\0'; t++; if (fs && strncmp(t, fs, strlen(fs))) { + fclose(fp); ERROR("block is mounted with wrong fs\n"); return NULL; } -- 2.11.0