libifupdown: Fixed bug where end pointer is not updated after realloc
This commit is contained in:
parent
1ee485666f
commit
4c64b5138b
1 changed files with 10 additions and 5 deletions
|
@ -122,12 +122,17 @@ append_to_buffer(char **buffer, size_t *buffer_len, char **end, const char *valu
|
||||||
/* Make sure there is enough room to add the value to the buffer */
|
/* Make sure there is enough room to add the value to the buffer */
|
||||||
if (*buffer_len < strlen (*buffer) + value_len + 2)
|
if (*buffer_len < strlen (*buffer) + value_len + 2)
|
||||||
{
|
{
|
||||||
*buffer = realloc (*buffer, *buffer_len * 2);
|
size_t end_offset = *end - *buffer;
|
||||||
if (*buffer == NULL)
|
char *tmp = realloc (*buffer, *buffer_len * 2);
|
||||||
/* XXX Here be dragons */
|
|
||||||
return false;
|
|
||||||
|
|
||||||
*buffer_len = *buffer_len * 2;
|
if (tmp != NULL)
|
||||||
|
{
|
||||||
|
*buffer = tmp;
|
||||||
|
*end = tmp + end_offset;
|
||||||
|
*buffer_len = *buffer_len * 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append value to buffer */
|
/* Append value to buffer */
|
||||||
|
|
Loading…
Reference in a new issue