@matheusbsbs / matheus-bagliano / commits / ce61595ea7
Fork 0

avoid NULL dereference on failed malloc

* builtin-remote.c (get_one_entry): Use xmalloc, not malloc. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jim Meyering committed Jun 14, 2009 at 21:46 UTC ce61595ea7eb3df22f6a943a38a273141f1af978
1 file changed +2 -2
builtin-remote.c
+2 -2
@@ -1285,7 +1285,7 @@ static int get_one_entry(struct remote *remote, void *priv)
1285
1286 if (remote->url_nr > 0) {
1287 utilp = &(string_list_append(remote->name, list)->util);
1288 - *utilp = malloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
1288 + *utilp = xmalloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
1289 strcpy((char *) *utilp, remote->url[0]);
1290 strcat((char *) *utilp, " (fetch)");
1291 } else
@@ -1300,7 +1300,7 @@ static int get_one_entry(struct remote *remote, void *priv)
1300 for (i = 0; i < url_nr; i++)
1301 {
1302 utilp = &(string_list_append(remote->name, list)->util);
1303 - *utilp = malloc(strlen(url[i])+strlen(" (push)")+1);
1303 + *utilp = xmalloc(strlen(url[i])+strlen(" (push)")+1);
1304 strcpy((char *) *utilp, url[i]);
1305 strcat((char *) *utilp, " (push)");
1306 }