Merge branch 'ao/path-use-xmalloc'

A possible oom error is now caught as a fatal error, instead of
continuing and dereferencing NULL.

* ao/path-use-xmalloc:
  path.c: use xmalloc() in add_to_trie()
This commit is contained in:
Junio C Hamano
2017-10-28 10:18:39 +09:00

2
path.c
View File

@ -192,7 +192,7 @@ static void *add_to_trie(struct trie *root, const char *key, void *value)
* Split this node: child will contain this node's * Split this node: child will contain this node's
* existing children. * existing children.
*/ */
child = malloc(sizeof(*child)); child = xmalloc(sizeof(*child));
memcpy(child->children, root->children, sizeof(root->children)); memcpy(child->children, root->children, sizeof(root->children));
child->len = root->len - i - 1; child->len = root->len - i - 1;