Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Incomplete
-
None
-
None
Description
A common pattern is
void function(GWBUF *queue)
|
{
|
...
|
queue = gwbuf_make_contiguous(queue);
|
}
|
However, gwbuf_make_contiguous behaves like realloc, that is, the memory allocation can fail and the function can return NULL, in which case the original buffer will leak and the code will steam ahead towards a SIGSEGV.
Correct way would be
void function(GWBUF *queue)
|
{
|
...
|
GWBUF *tmp = gwbuf_make_contiguous(queue);
|
if (tmp)
|
{
|
queue = tmp;
|
}
|
else
|
{
|
// Handle problem.
|
}
|
}
|