]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/hwdb/hwdb.c
coccinelle: add reallocarray() coccinelle script
[thirdparty/systemd.git] / src / hwdb / hwdb.c
index 4540260f9b869f4e195184810e0c50c75cb9e810..f27f60e9777d599e99e1e78caf72fa0cd0301b5c 100644 (file)
@@ -103,7 +103,7 @@ static int node_add_child(struct trie *trie, struct trie_node *node, struct trie
         struct trie_child_entry *child;
 
         /* extend array, add new entry, sort for bisection */
-        child = realloc(node->children, (node->children_count + 1) * sizeof(struct trie_child_entry));
+        child = reallocarray(node->children, node->children_count + 1, sizeof(struct trie_child_entry));
         if (!child)
                 return -ENOMEM;
 
@@ -197,7 +197,7 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
         }
 
         /* extend array, add new entry, sort for bisection */
-        val = realloc(node->values, (node->values_count + 1) * sizeof(struct trie_value_entry));
+        val = reallocarray(node->values, node->values_count + 1, sizeof(struct trie_value_entry));
         if (!val)
                 return -ENOMEM;
         trie->values_count++;