Skip to content

Commit c137503

Browse files
author
drscholl
committed
avoid coredump in queue_data() when buffer_new() fails
1 parent c795063 commit c137503

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

buffer.c

+15
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ buffer_queue (BUFFER * b, char *d, int dsize)
5959
b->next = buffer_new ();
6060
b = b->next;
6161
}
62+
if(!b)
63+
{
64+
/*something really bad just happened! no choice but to close
65+
this connection since it will be out of sync*/
66+
buffer_free(r);
67+
return 0;
68+
}
6269
count = dsize;
6370
/* dsize could be greater than what is allocated */
6471
if (count > b->datamax - b->datasize)
@@ -379,7 +386,15 @@ queue_data (CONNECTION * con, char *s, int ssize)
379386
{
380387
ASSERT (validate_connection (con));
381388
if (ISSERVER (con))
389+
{
382390
con->sopt->outbuf = buffer_queue (con->sopt->outbuf, s, ssize);
391+
if(!con->sopt->outbuf)
392+
con->destroy=1; /*error queuing the data, close connection*/
393+
}
383394
else
395+
{
384396
con->sendbuf = buffer_queue (con->sendbuf, s, ssize);
397+
if(!con->sendbuf)
398+
con->destroy=1; /*error queuing the data, close connection*/
399+
}
385400
}

0 commit comments

Comments
 (0)