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:
Dario Casalinuovo
2016-04-06 00:28:42 +02:00
parent 99741be9f2
commit 2f611cf798
+3 -1
View File
@@ -199,6 +199,8 @@ read_string_from_buffer(const void **_buffer, char **_string, ssize_t size)
memcpy(string, buffer, length);
string[length] = '\0';
free(*_string);
*_buffer = static_cast<const void *>(buffer + length);
*_string = string;
return B_OK;
@@ -2204,7 +2206,7 @@ BDiscreteParameter::Unflatten(type_code code, const void* buffer, ssize_t size)
MakeEmpty();
for (int32 i = 0; i < count; i++) {
char* name;
char* name = NULL;
if (read_string_from_buffer(&buffer, &name, size_left(size, bufferStart,
buffer)) < B_OK)
return B_BAD_DATA;