summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-17 19:53:01 +0200
committerAnthony G. Basile <blueness@gentoo.org>2014-09-17 20:23:00 -0400
commitdad4b71c8a0d91724d646c90dca6b64c482cf739 (patch)
tree39b46c30f82af932889be7dca4532922227d9950 /src
parent744749bd2e6241929d028cab74c024019ba2cb14 (diff)
udev: rules - close empty file
If the file is found to be empty, we exit early without closing the file first. Found by coverity. Fixes CID #1237759. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/udev/udev-rules.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 4f6d492848..b8fc35e11a 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1580,7 +1580,7 @@ invalid:
}
static int parse_file(struct udev_rules *rules, const char *filename) {
- FILE *f;
+ _cleanup_fclose_ FILE *f = NULL;
unsigned int first_token;
unsigned int filename_off;
char line[UTIL_LINE_SIZE];
@@ -1638,7 +1638,6 @@ static int parse_file(struct udev_rules *rules, const char *filename) {
}
add_rule(rules, key, filename, filename_off, line_nr);
}
- fclose(f);
/* link GOTOs to LABEL rules in this file to be able to fast-forward */
for (i = first_token+1; i < rules->token_cur; i++) {