aboutsummaryrefslogtreecommitdiffstats
path: root/gtp
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-04-25 13:00:10 +0200
committerHarald Welte <laforge@gnumonks.org>2016-04-29 13:01:06 +0200
commitf89dc4e127eea6addea6a7b45eb96da8c1053ba4 (patch)
tree6e2d49e102b5de0fb0b72b64f1fda28e6634ad15 /gtp
parentb29ff1da554a2654cc593ea243e29cd7883c92da (diff)
queue_new(): fix NULL dereference on allocation failure
Coverity complains about a 'Dereference before null check' on *queue. So, push the NULL check further up. Though I doubt that 'return EOF' is the proper way to handle allocation failure, this patch is only about the NULL dereference. Fixes: CID#57918
Diffstat (limited to 'gtp')
-rw-r--r--gtp/queue.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gtp/queue.c b/gtp/queue.c
index 7c971b0..5b4d849 100644
--- a/gtp/queue.c
+++ b/gtp/queue.c
@@ -127,16 +127,15 @@ int queue_new(struct queue_t **queue)
if (QUEUE_DEBUG)
printf("queue_new\n");
*queue = calloc(1, sizeof(struct queue_t));
+ if (!(*queue))
+ return EOF;
(*queue)->next = 0;
(*queue)->first = -1;
(*queue)->last = -1;
if (QUEUE_DEBUG)
queue_print(*queue);
- if (*queue)
- return 0;
- else
- return EOF;
+ return 0;
}
/*! \brief Deallocates queue structure */