summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4886b89)
raw | patch | inline | side by side (parent: 4886b89)
author | Dotan Barak <dotanba@gmail.com> | |
Tue, 9 Sep 2008 18:57:10 +0000 (21:57 +0300) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 9 Sep 2008 23:28:05 +0000 (16:28 -0700) |
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>
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>
builtin-http-fetch.c | patch | blob | history | |
git.c | patch | blob | history | |
http-push.c | patch | blob | history | |
http.c | patch | blob | history | |
remote.c | patch | blob | history |
diff --git a/builtin-http-fetch.c b/builtin-http-fetch.c
index 3a062487a7eacd01ed824b46a9124dd343cd2e60..ea2b6896519aeb5912f70b62a451a1d1456695e8 100644 (file)
--- a/builtin-http-fetch.c
+++ b/builtin-http-fetch.c
}
url = argv[arg];
if (url && url[strlen(url)-1] != '/') {
- rewritten_url = malloc(strlen(url)+2);
+ rewritten_url = xmalloc(strlen(url)+2);
strcpy(rewritten_url, url);
strcat(rewritten_url, "/");
url = rewritten_url;
index adf73524098bdb308dea17b651536517a1588fef..905acc2f2cd591bd3bd65008f7a72a5642a21f35 100644 (file)
--- a/git.c
+++ b/git.c
if (sizeof(ext) > 1) {
i = strlen(argv[0]) - strlen(ext);
if (i > 0 && !strcmp(argv[0] + i, ext)) {
- char *argv0 = strdup(argv[0]);
+ char *argv0 = xstrdup(argv[0]);
argv[0] = cmd = argv0;
argv0[i] = '\0';
}
diff --git a/http-push.c b/http-push.c
index 68052888570af7d09535db8831b8cf3ef2881589..c9dd9a1f6475cc8772b1e0f528a9f54751d6445a 100644 (file)
--- a/http-push.c
+++ b/http-push.c
no_pragma_header = curl_slist_append(no_pragma_header, "Pragma:");
if (remote->url && remote->url[strlen(remote->url)-1] != '/') {
- rewritten_url = malloc(strlen(remote->url)+2);
+ rewritten_url = xmalloc(strlen(remote->url)+2);
strcpy(rewritten_url, remote->url);
strcat(rewritten_url, "/");
remote->url = rewritten_url;
index 1108ab4a3101fb4768cad420ccfdb52d87890a18..07889367040c4b49ca335262a69cfd91ba637f3c 100644 (file)
--- a/http.c
+++ b/http.c
void add_fill_function(void *data, int (*fill)(void *))
{
- struct fill_chain *new = malloc(sizeof(*new));
+ struct fill_chain *new = xmalloc(sizeof(*new));
struct fill_chain **linkp = &fill_cfg;
new->data = data;
new->fill = fill;
diff --git a/remote.c b/remote.c
index 3ef09a44a14622bb175d2a18bc46c946cde9a8a1..3f3c789653a23e829369429da093c1193b53b015 100644 (file)
--- a/remote.c
+++ b/remote.c
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);
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;