aboutsummaryrefslogtreecommitdiff
path: root/remote.c
diff options
context:
space:
mode:
authorDotan Barak <dotanba@gmail.com>2008-09-09 21:57:10 +0300
committerJunio C Hamano <gitster@pobox.com>2008-09-09 16:28:05 -0700
commite8eec71d6e79c176d34dc8fda8780ed4dee447a2 (patch)
tree67faf2bc865ed17e29ab2ad042a526bc6383a7e3 /remote.c
parent4886b89f8fde57b76738c96761eecbfbd0b13112 (diff)
downloadgit-e8eec71d6e79c176d34dc8fda8780ed4dee447a2.tar.gz
git-e8eec71d6e79c176d34dc8fda8780ed4dee447a2.tar.xz
Use xmalloc() and friends to catch allocation failures
Some places use the standard malloc/strdup without checking if the allocation was successful; they should use xmalloc/xstrdup that check the memory allocation result. Signed-off-by: Dotan Barak <dotanba@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote.c')
-rw-r--r--remote.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/remote.c b/remote.c
index 3ef09a44a..3f3c78965 100644
--- a/remote.c
+++ b/remote.c
@@ -69,7 +69,7 @@ static const char *alias_url(const char *url)
if (!longest)
return url;
- ret = malloc(rewrite[longest_i]->baselen +
+ ret = xmalloc(rewrite[longest_i]->baselen +
(strlen(url) - longest->len) + 1);
strcpy(ret, rewrite[longest_i]->base);
strcpy(ret + rewrite[longest_i]->baselen, url + longest->len);
@@ -152,7 +152,7 @@ static struct branch *make_branch(const char *name, int len)
ret->name = xstrndup(name, len);
else
ret->name = xstrdup(name);
- refname = malloc(strlen(name) + strlen("refs/heads/") + 1);
+ refname = xmalloc(strlen(name) + strlen("refs/heads/") + 1);
strcpy(refname, "refs/heads/");
strcpy(refname + strlen("refs/heads/"), ret->name);
ret->refname = refname;