From 875c0851d0d2a68521a52e493a49d407b72193cb Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Fri, 7 Mar 2008 17:52:20 +0000 Subject: [PATCH] Fri Mar 7 12:31:52 EST 2008 Pekka.Pessi@nokia.com * sres_blocking.c: validating calloc() return value git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7828 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../libsofia-sip-ua/sresolv/sres_blocking.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c index 58751b1323..2c55f5a6f3 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c +++ b/libs/sofia-sip/libsofia-sip-ua/sresolv/sres_blocking.c @@ -113,6 +113,9 @@ int sres_blocking_update(sres_blocking_t *b, { int i, N = b->n_sockets; + if (b == NULL) + return -1; + if (old_socket == new_socket) { if (old_socket == INVALID_SOCKET) { free(b); /* Destroy us */ @@ -233,11 +236,13 @@ sres_blocking_t *sres_set_blocking(sres_resolver_t *res) /* Create a synchronous (blocking) interface towards resolver */ b = calloc(1, sizeof *b); - for (i = 0; i < SRES_MAX_NAMESERVERS; i++) - b->fds[i].fd = INVALID_SOCKET; + if (b) { + for (i = 0; i < SRES_MAX_NAMESERVERS; i++) + b->fds[i].fd = INVALID_SOCKET; - if (!sres_resolver_set_async(res, sres_blocking_update, b, 0)) { - free(b), b = NULL; + if (!sres_resolver_set_async(res, sres_blocking_update, b, 0)) { + free(b), b = NULL; + } } return b;