Commit ac3d8ec1 authored by Pekka Pessi's avatar Pekka Pessi

sres_blocking.c: validating calloc() return value

darcs-hash:20080307173152-65a35-339909e99a3204a54eefd187c3f9dfb3a22e8716.gz
parent becf5a18
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment