All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH tabled] server/server.c don't deref NULL on failed malloc
@ 2010-09-23 11:03 Jim Meyering
  2010-09-23 14:07 ` Pete Zaitcev
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Meyering @ 2010-09-23 11:03 UTC (permalink / raw)
  To: Project Hail



Signed-off-by: Jim Meyering <meyering@redhat.com>
---
Just noticed that sometimes tabled uses this idiom:
  if (!(key = malloc(klen + 1)))
and sometimes this:
  if ((key = malloc(klen + 1)) == NULL)
This time I used "... == NULL".

 server/server.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/server/server.c b/server/server.c
index 2b4ef1c..3cec5ae 100644
--- a/server/server.c
+++ b/server/server.c
@@ -306,7 +306,8 @@ static char *pathtokey(const char *path)
 		return NULL;
 	klen = end - path;

-	key = malloc(klen + 1);
+	if ((key = malloc(klen + 1)) == NULL)
+		return NULL;
 	memcpy(key, path, klen);
 	key[klen] = 0;

--
1.7.3.234.g7bba3

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

end of thread, other threads:[~2010-09-23 19:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-23 11:03 [PATCH tabled] server/server.c don't deref NULL on failed malloc Jim Meyering
2010-09-23 14:07 ` Pete Zaitcev
2010-09-23 19:41   ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.