summaryrefslogtreecommitdiff
path: root/udev_rules_parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'udev_rules_parse.c')
-rw-r--r--udev_rules_parse.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/udev_rules_parse.c b/udev_rules_parse.c
index 4580a779c6..cededf002d 100644
--- a/udev_rules_parse.c
+++ b/udev_rules_parse.c
@@ -650,10 +650,12 @@ int udev_rules_init(struct udev_rules *rules, int resolve_names)
void udev_rules_close(struct udev_rules *rules)
{
- if (rules->mapped)
- file_unmap(rules->buf, rules->bufsize);
- else
- free(rules->buf);
-
- rules->buf = NULL;
+ if (rules->buf) {
+ if (rules->mapped) {
+ rules->mapped = 0;
+ file_unmap(rules->buf, rules->bufsize);
+ } else
+ free(rules->buf);
+ rules->buf = NULL;
+ }
}