udev-rules: fix possible assertion
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 15 Nov 2018 09:46:23 +0000 (18:46 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 15 Nov 2018 14:50:27 +0000 (15:50 +0100)
On 'remove' action, event->dev_db_clone is NULL. So, `IMPORT{db}` rule
on 'remove' action triggers assertion. This fixes the issue.

src/udev/udev-rules.c

index dcde65c..c52f93a 100644 (file)
@@ -2043,7 +2043,8 @@ int udev_rules_apply_to_event(
                         const char *key;
 
                         key = rules_str(rules, cur->key.value_off);
-                        if (sd_device_get_property_value(event->dev_db_clone, key, &val) >= 0)
+                        if (event->dev_db_clone &&
+                            sd_device_get_property_value(event->dev_db_clone, key, &val) >= 0)
                                 device_add_property(dev, key, val);
                         else if (cur->key.op != OP_NOMATCH)
                                 goto nomatch;