Skip to content

Commit

Permalink
BParameterGroup: Fix memory leak
Browse files Browse the repository at this point in the history
* Fixes #12706.
* The issue has been reported by Cédric Degea with the fix
included. Thanks!
  • Loading branch information
Numerio committed Apr 5, 2016
1 parent 99741be commit 2f611cf
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/kits/media/ParameterWeb.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2f611cf

Please sign in to comment.