From: Jim Meyering Date: Sun, 14 Jun 2009 19:46:10 +0000 (+0200) Subject: avoid NULL dereference on failed malloc X-Git-Tag: v1.6.4-rc0~46^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ce61595ea7eb3df22f6a943a38a273141f1af978;p=git-core%2Fgit.git avoid NULL dereference on failed malloc * builtin-remote.c (get_one_entry): Use xmalloc, not malloc. Signed-off-by: Jim Meyering Signed-off-by: Junio C Hamano --- diff --git a/builtin-remote.c b/builtin-remote.c index 3f6f5c231..fd0e63c5d 100644 --- a/builtin-remote.c +++ b/builtin-remote.c @@ -1285,7 +1285,7 @@ static int get_one_entry(struct remote *remote, void *priv) if (remote->url_nr > 0) { utilp = &(string_list_append(remote->name, list)->util); - *utilp = malloc(strlen(remote->url[0])+strlen(" (fetch)")+1); + *utilp = xmalloc(strlen(remote->url[0])+strlen(" (fetch)")+1); strcpy((char *) *utilp, remote->url[0]); strcat((char *) *utilp, " (fetch)"); } else @@ -1300,7 +1300,7 @@ static int get_one_entry(struct remote *remote, void *priv) for (i = 0; i < url_nr; i++) { utilp = &(string_list_append(remote->name, list)->util); - *utilp = malloc(strlen(url[i])+strlen(" (push)")+1); + *utilp = xmalloc(strlen(url[i])+strlen(" (push)")+1); strcpy((char *) *utilp, url[i]); strcat((char *) *utilp, " (push)"); }