path.c: use xmalloc() in add_to_trie()
authorAndrey Okoshkin <a.okoshkin@samsung.com>
Tue, 24 Oct 2017 15:15:05 +0000 (18:15 +0300)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Oct 2017 07:16:22 +0000 (16:16 +0900)
Add usage of xmalloc() instead of malloc() in add_to_trie() as xmalloc wraps
and checks memory allocation result.

Signed-off-by: Andrey Okoshkin <a.okoshkin@samsung.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c
diff --git a/path.c b/path.c
index 0349a0ab7b8656130df89ef007f5921797cdab3e..9d518992d843ed0c0a3a4063fa49e6a26b0a0f36 100644 (file)
--- a/path.c
+++ b/path.c
@@ -190,7 +190,7 @@ static void *add_to_trie(struct trie *root, const char *key, void *value)
                 * Split this node: child will contain this node's
                 * existing children.
                 */
-               child = malloc(sizeof(*child));
+               child = xmalloc(sizeof(*child));
                memcpy(child->children, root->children, sizeof(root->children));
 
                child->len = root->len - i - 1;