Skip to content

Commit ce61595

Browse files
meyeringgitster
authored andcommitted
avoid NULL dereference on failed malloc
* builtin-remote.c (get_one_entry): Use xmalloc, not malloc. Signed-off-by: Jim Meyering <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a4b4cd commit ce61595

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin-remote.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ static int get_one_entry(struct remote *remote, void *priv)
12851285

12861286
if (remote->url_nr > 0) {
12871287
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);
12891289
strcpy((char *) *utilp, remote->url[0]);
12901290
strcat((char *) *utilp, " (fetch)");
12911291
} else
@@ -1300,7 +1300,7 @@ static int get_one_entry(struct remote *remote, void *priv)
13001300
for (i = 0; i < url_nr; i++)
13011301
{
13021302
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);
13041304
strcpy((char *) *utilp, url[i]);
13051305
strcat((char *) *utilp, " (push)");
13061306
}

0 commit comments

Comments
 (0)