diff options
author | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-10 00:48:16 +0000 |
---|---|---|
committer | Alan Coopersmith <Alan.Coopersmith@sun.com> | 2006-03-10 00:48:16 +0000 |
commit | 23198133e90c34508e5d0c0f1314bf167bf3a98c (patch) | |
tree | 2aabb11a515de8a29770780d31db31953f843dcc | |
parent | 17b0d313c80ca754348ca8b92ce117918a2f8d43 (diff) |
Coverity ids #7689, 7690, 7691: When malloc fails, don't just print an
error and continue on using the NULL pointer, return NULL to the
caller.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | socket.c | 16 |
2 files changed, 19 insertions, 4 deletions
@@ -1,3 +1,10 @@ +2006-03-09 Alan Coopersmith <alan.coopersmith@sun.com> + + * socket.c: (CreateSocklistEntry): + Coverity ids #7689, 7690, 7691: + When malloc fails, don't just print an error and continue on using + the NULL pointer, return NULL to the caller. + 2006-03-01 Matthias Hopf <mhopf@suse.de> * greeter/verify.c: (PAM_conv): @@ -1,4 +1,4 @@ -/* $XdotOrg: xc/programs/xdm/socket.c,v 1.3 2004/07/06 00:44:39 anholt Exp $ */ +/* $XdotOrg: app/xdm/socket.c,v 1.4 2005/07/05 18:52:33 alanc Exp $ */ /* $Xorg: socket.c,v 1.4 2001/02/09 02:05:40 xorgcvs Exp $ */ /* @@ -247,8 +247,10 @@ static struct socklist * CreateSocklistEntry(ARRAY8Ptr addr) { struct socklist *s = malloc (sizeof(struct socklist)); - if (s == NULL) + if (s == NULL) { LogOutOfMem("CreateSocklistEntry"); + return NULL; + } bzero(s, sizeof(struct socklist)); @@ -256,8 +258,11 @@ CreateSocklistEntry(ARRAY8Ptr addr) { struct sockaddr_in *sin; sin = malloc (sizeof(struct sockaddr_in)); - if (sin == NULL) + if (sin == NULL) { LogOutOfMem("CreateSocklistEntry"); + free(s); + return NULL; + } s->addr = (struct sockaddr *) sin; bzero (sin, sizeof (struct sockaddr_in)); @@ -275,8 +280,11 @@ CreateSocklistEntry(ARRAY8Ptr addr) { struct sockaddr_in6 *sin6; sin6 = malloc (sizeof(struct sockaddr_in6)); - if (sin6 == NULL) + if (sin6 == NULL) { LogOutOfMem("CreateSocklistEntry"); + free(s); + return NULL; + } s->addr = (struct sockaddr *) sin6; bzero (sin6, sizeof (struct sockaddr_in6)); |