path: root/builtin/apply.c
diff options
authorThomas Rast <>2013-06-21 11:38:00 (GMT)
committerJunio C Hamano <>2013-06-21 15:36:07 (GMT)
commit212eb96a96e256933a76e48d85fa4f500bed0dee (patch)
tree114f51785e5003bb54b424f0bf5eabd574b53cc5 /builtin/apply.c
parent0ce2e396ee9fb0fa07e8381b338e49859dbf03db (diff)
apply: carefully strdup a possibly-NULL name
2901bbe (apply: free patch->{def,old,new}_name fields, 2012-03-21) cleaned up the memory management of filenames in the patches, but forgot that find_name_traditional() can return NULL as a way of saying "I couldn't find a name". That NULL unfortunately gets passed into xstrdup() next, resulting in a segfault. Use null_strdup() so as to safely propagate the null, which will let us emit the correct error message. Reported-by: DevHC on #git Signed-off-by: Thomas Rast <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/apply.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index b4428ea..f69a864 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -898,7 +898,7 @@ static void parse_traditional_patch(const char *first, const char *second, struc
patch->old_name = name;
} else {
patch->old_name = name;
- patch->new_name = xstrdup(name);
+ patch->new_name = null_strdup(name);
if (!name)