Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
avoid NULL dereference on failed malloc
author
Jim Meyering
<jim@meyering.net>
Sun, 14 Jun 2009 19:46:10 +0000
(21:46 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Sun, 14 Jun 2009 20:35:40 +0000
(13:35 -0700)
* 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>
builtin-remote.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
4a4b4cd
)
diff --git
a/builtin-remote.c
b/builtin-remote.c
index 3f6f5c2318d49fe05df78e7dfd8338383c4b39a1..fd0e63c5dce1399ab649585c942ede0093d5c634 100644
(file)
--- 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);
if (remote->url_nr > 0) {
utilp = &(string_list_append(remote->name, list)->util);
- *utilp = malloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
+ *utilp =
x
malloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
strcpy((char *) *utilp, remote->url[0]);
strcat((char *) *utilp, " (fetch)");
} else
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);
for (i = 0; i < url_nr; i++)
{
utilp = &(string_list_append(remote->name, list)->util);
- *utilp = malloc(strlen(url[i])+strlen(" (push)")+1);
+ *utilp =
x
malloc(strlen(url[i])+strlen(" (push)")+1);
strcpy((char *) *utilp, url[i]);
strcat((char *) *utilp, " (push)");
}
strcpy((char *) *utilp, url[i]);
strcat((char *) *utilp, " (push)");
}