summaryrefslogtreecommitdiff
path: root/src/udev/udev-rules.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-17 19:53:01 +0200
committerTom Gundersen <teg@jklm.no>2014-09-17 19:55:23 +0200
commit6c8aaf0c1bf2a04010ae7125a08ceb51e7058712 (patch)
tree352804381ead7ad0d226635933db695d25ba314d /src/udev/udev-rules.c
parent6f42877282a7237f3aa840403047b7cc18d7faa6 (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.
Diffstat (limited to 'src/udev/udev-rules.c')
-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 2a691f6ab7..3bc25f7c26 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1575,7 +1575,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];
@@ -1633,7 +1633,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++) {