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;