fix memory leak issue on Transcoder

This commit is contained in:
Nomango 2019-09-26 15:10:28 +08:00
parent c7d2295f4d
commit b1cf985e44
2 changed files with 23 additions and 15 deletions

View File

@ -260,12 +260,15 @@ namespace kiwano
&sample_buffer_length &sample_buffer_length
); );
if (SUCCEEDED(hr) && sample_buffer_length <= max_stream_size) if (position + sample_buffer_length >= max_stream_size)
{ {
for (DWORD i = 0; i < sample_buffer_length; i++) hr = E_FAIL;
{
data[position++] = audio_data[i];
} }
if (SUCCEEDED(hr))
{
::memcpy(data + position, audio_data, sample_buffer_length);
position += sample_buffer_length;
hr = buffer->Unlock(); hr = buffer->Unlock();
} }
} }
@ -281,6 +284,11 @@ namespace kiwano
wave_data_ = data; wave_data_ = data;
wave_size_ = position; wave_size_ = position;
} }
else
{
delete[] data;
data = nullptr;
}
} }
} }