git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] avoid NULL dereference on failed malloc
@ 2009-06-14 19:46 Jim Meyering
  2009-06-15  7:49 ` Michael J Gruber
  0 siblings, 1 reply; 9+ messages in thread
From: Jim Meyering @ 2009-06-14 19:46 UTC (permalink / raw)
  To: git list


* builtin-remote.c (get_one_entry): Use xmalloc, not malloc.

Signed-off-by: Jim Meyering <meyering@redhat.com>
---
 builtin-remote.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin-remote.c b/builtin-remote.c
index 709f8a6..406fb85 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -1282,7 +1282,7 @@ static int get_one_entry(struct remote *remote, void *priv)

 	if (remote->url_nr > 0) {
 		utilp = &(string_list_append(remote->name, list)->util);
-		*utilp = malloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
+		*utilp = xmalloc(strlen(remote->url[0])+strlen(" (fetch)")+1);
 		strcpy((char *) *utilp, remote->url[0]);
 		strcat((char *) *utilp, " (fetch)");
 	} else
@@ -1297,7 +1297,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);
-		*utilp = malloc(strlen(url[i])+strlen(" (push)")+1);
+		*utilp = xmalloc(strlen(url[i])+strlen(" (push)")+1);
 		strcpy((char *) *utilp, url[i]);
 		strcat((char *) *utilp, " (push)");
 	}
--
1.6.3.2.406.gd6a466

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-06-22 22:28 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-14 19:46 [PATCH] avoid NULL dereference on failed malloc Jim Meyering
2009-06-15  7:49 ` Michael J Gruber
2009-06-15 20:45   ` [PATCH] builtin-remote: (get_one_entry): use strbuf Bert Wesarg
2009-06-16  7:39     ` Michael J Gruber
2009-06-16  7:56       ` Bert Wesarg
2009-06-16 10:49         ` Michael J Gruber
2009-06-22  8:24           ` Bert Wesarg
2009-06-22 21:32             ` Jeff King
2009-06-22 22:27               ` [PATCH v2] " Bert Wesarg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).