Fix for NULL buffer past to gwbuf_length
This commit is contained in:
@ -284,7 +284,11 @@ unsigned int
|
|||||||
gwbuf_length(GWBUF *head)
|
gwbuf_length(GWBUF *head)
|
||||||
{
|
{
|
||||||
int rval = 0;
|
int rval = 0;
|
||||||
CHK_GWBUF(head);
|
|
||||||
|
if (head)
|
||||||
|
{
|
||||||
|
CHK_GWBUF(head);
|
||||||
|
}
|
||||||
while (head)
|
while (head)
|
||||||
{
|
{
|
||||||
rval += GWBUF_LENGTH(head);
|
rval += GWBUF_LENGTH(head);
|
||||||
|
@ -758,7 +758,10 @@ int below_water;
|
|||||||
* the routine that drains the queue data, so we should
|
* the routine that drains the queue data, so we should
|
||||||
* not have a race condition on the event.
|
* not have a race condition on the event.
|
||||||
*/
|
*/
|
||||||
qlen = gwbuf_length(queue);
|
if (queue)
|
||||||
|
qlen = gwbuf_length(queue);
|
||||||
|
else
|
||||||
|
qlen = 0;
|
||||||
atomic_add(&dcb->writeqlen, qlen);
|
atomic_add(&dcb->writeqlen, qlen);
|
||||||
dcb->writeq = gwbuf_append(dcb->writeq, queue);
|
dcb->writeq = gwbuf_append(dcb->writeq, queue);
|
||||||
dcb->stats.n_buffered++;
|
dcb->stats.n_buffered++;
|
||||||
@ -872,7 +875,14 @@ int below_water;
|
|||||||
* for suspended write.
|
* for suspended write.
|
||||||
*/
|
*/
|
||||||
dcb->writeq = queue;
|
dcb->writeq = queue;
|
||||||
qlen = gwbuf_length(queue);
|
if (queue)
|
||||||
|
{
|
||||||
|
qlen = gwbuf_length(queue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qlen = 0;
|
||||||
|
}
|
||||||
atomic_add(&dcb->writeqlen, qlen);
|
atomic_add(&dcb->writeqlen, qlen);
|
||||||
|
|
||||||
if (queue != NULL)
|
if (queue != NULL)
|
||||||
@ -1075,7 +1085,8 @@ printDCB(DCB *dcb)
|
|||||||
printf("\tDCB state: %s\n", gw_dcb_state2string(dcb->state));
|
printf("\tDCB state: %s\n", gw_dcb_state2string(dcb->state));
|
||||||
if (dcb->remote)
|
if (dcb->remote)
|
||||||
printf("\tConnected to: %s\n", dcb->remote);
|
printf("\tConnected to: %s\n", dcb->remote);
|
||||||
printf("\tQueued write data: %d\n", gwbuf_length(dcb->writeq));
|
if (dcb->writeq)
|
||||||
|
printf("\tQueued write data: %d\n",gwbuf_length(dcb->writeq));
|
||||||
printf("\tStatistics:\n");
|
printf("\tStatistics:\n");
|
||||||
printf("\t\tNo. of Reads: %d\n", dcb->stats.n_reads);
|
printf("\t\tNo. of Reads: %d\n", dcb->stats.n_reads);
|
||||||
printf("\t\tNo. of Writes: %d\n", dcb->stats.n_writes);
|
printf("\t\tNo. of Writes: %d\n", dcb->stats.n_writes);
|
||||||
@ -1150,7 +1161,8 @@ dprintDCB(DCB *pdcb, DCB *dcb)
|
|||||||
if (dcb->remote)
|
if (dcb->remote)
|
||||||
dcb_printf(pdcb, "\tConnected to: %s\n", dcb->remote);
|
dcb_printf(pdcb, "\tConnected to: %s\n", dcb->remote);
|
||||||
dcb_printf(pdcb, "\tOwning Session: %d\n", dcb->session);
|
dcb_printf(pdcb, "\tOwning Session: %d\n", dcb->session);
|
||||||
dcb_printf(pdcb, "\tQueued write data: %d\n", gwbuf_length(dcb->writeq));
|
if (dcb->writeq)
|
||||||
|
dcb_printf(pdcb, "\tQueued write data: %d\n", gwbuf_length(dcb->writeq));
|
||||||
dcb_printf(pdcb, "\tStatistics:\n");
|
dcb_printf(pdcb, "\tStatistics:\n");
|
||||||
dcb_printf(pdcb, "\t\tNo. of Reads: %d\n", dcb->stats.n_reads);
|
dcb_printf(pdcb, "\t\tNo. of Reads: %d\n", dcb->stats.n_reads);
|
||||||
dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", dcb->stats.n_writes);
|
dcb_printf(pdcb, "\t\tNo. of Writes: %d\n", dcb->stats.n_writes);
|
||||||
@ -1552,7 +1564,7 @@ int rval = 1;
|
|||||||
/**
|
/**
|
||||||
* Remove a callback from the callback list for the DCB
|
* Remove a callback from the callback list for the DCB
|
||||||
*
|
*
|
||||||
* Searches down the linked list to find he callback with a matching reason, function
|
* Searches down the linked list to find the callback with a matching reason, function
|
||||||
* and userdata.
|
* and userdata.
|
||||||
*
|
*
|
||||||
* @param dcb The DCB to add the callback to
|
* @param dcb The DCB to add the callback to
|
||||||
|
Reference in New Issue
Block a user