]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-device: use trivial_hash_ops_free_free for managing match sysattrs or properties 17267/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Oct 2020 13:41:34 +0000 (22:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Oct 2020 13:45:15 +0000 (22:45 +0900)
This fixes an issue caused by eb1c1dc029c91750e6255c3fd844b4f4bf238fab.

Before the commit, multiple values can be specified for the same
sysattr or property.

Fixes #17259.

src/libsystemd/sd-device/device-enumerator.c

index f3bac17ca3a7720607a82d69dfd907fe61ac6ef1..2d1ce7988873366d697dac7bf834b18ed25131bc 100644 (file)
@@ -118,7 +118,7 @@ _public_ int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumer
         else
                 hashmap = &enumerator->nomatch_sysattr;
 
-        r = hashmap_put_strdup(hashmap, sysattr, value);
+        r = hashmap_put_strdup_full(hashmap, &trivial_hash_ops_free_free, sysattr, value);
         if (r <= 0)
                 return r;
 
@@ -133,7 +133,7 @@ _public_ int sd_device_enumerator_add_match_property(sd_device_enumerator *enume
         assert_return(enumerator, -EINVAL);
         assert_return(property, -EINVAL);
 
-        r = hashmap_put_strdup(&enumerator->match_property, property, value);
+        r = hashmap_put_strdup_full(&enumerator->match_property, &trivial_hash_ops_free_free, property, value);
         if (r <= 0)
                 return r;