Add GWBUF_POINTER_IN_BUFFER macro; add extra free calls to remove memory leaks.
This commit is contained in:
@ -168,6 +168,9 @@ typedef struct gwbuf {
|
||||
/*< Consume a number of bytes in the buffer */
|
||||
#define GWBUF_CONSUME(b, bytes) ((b)->start = bytes > ((char *)(b)->end - (char *)(b)->start) ? (b)->end : (void *)((char *)(b)->start + (bytes)));
|
||||
|
||||
/*< Check if a given pointer is within the buffer */
|
||||
#define GWBUF_POINTER_IN_BUFFER (ptr, b) ((char *)(ptr) >= (char *)(b)->start && (char *)(ptr) < (char *)(b)->end)
|
||||
|
||||
/*< Consume a complete buffer */
|
||||
#define GWBUF_CONSUME_ALL(b) gwbuf_consume((b), GWBUF_LENGTH((b)))
|
||||
|
||||
|
@ -406,6 +406,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
}
|
||||
else
|
||||
{
|
||||
gwbuf_free(errbuf);
|
||||
dcb->dcb_errhandle_called = true;
|
||||
dcb_close(dcb);
|
||||
rc = 1;
|
||||
|
@ -817,6 +817,10 @@ int gw_read_client_event(
|
||||
"Session will be closed.")));
|
||||
}
|
||||
rc = 1;
|
||||
while (read_buffer)
|
||||
{
|
||||
read_buffer = gwbuf_consume(read_buffer, GWBUF_LENGTH(read_buffer));
|
||||
}
|
||||
goto return_rc;
|
||||
}
|
||||
}
|
||||
@ -828,6 +832,10 @@ int gw_read_client_event(
|
||||
2,
|
||||
0,
|
||||
"failed to create new session");
|
||||
while (read_buffer)
|
||||
{
|
||||
read_buffer = gwbuf_consume(read_buffer, GWBUF_LENGTH(read_buffer));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1204,6 +1212,10 @@ int gw_read_client_event(
|
||||
"Session will be closed.")));
|
||||
|
||||
}
|
||||
while (read_buffer)
|
||||
{
|
||||
read_buffer = gwbuf_consume(read_buffer, GWBUF_LENGTH(read_buffer));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user