BParameterGroup: Fix memory leak
* Fixes #12706. * The issue has been reported by Cédric Degea with the fix included. Thanks!
This commit is contained in:
@@ -199,6 +199,8 @@ read_string_from_buffer(const void **_buffer, char **_string, ssize_t size)
|
|||||||
memcpy(string, buffer, length);
|
memcpy(string, buffer, length);
|
||||||
string[length] = '\0';
|
string[length] = '\0';
|
||||||
|
|
||||||
|
free(*_string);
|
||||||
|
|
||||||
*_buffer = static_cast<const void *>(buffer + length);
|
*_buffer = static_cast<const void *>(buffer + length);
|
||||||
*_string = string;
|
*_string = string;
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -2204,7 +2206,7 @@ BDiscreteParameter::Unflatten(type_code code, const void* buffer, ssize_t size)
|
|||||||
MakeEmpty();
|
MakeEmpty();
|
||||||
|
|
||||||
for (int32 i = 0; i < count; i++) {
|
for (int32 i = 0; i < count; i++) {
|
||||||
char* name;
|
char* name = NULL;
|
||||||
if (read_string_from_buffer(&buffer, &name, size_left(size, bufferStart,
|
if (read_string_from_buffer(&buffer, &name, size_left(size, bufferStart,
|
||||||
buffer)) < B_OK)
|
buffer)) < B_OK)
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
|||||||
Reference in New Issue
Block a user