mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-12 16:46:42 +02:00
Use realloc to avoid memleak
This commit is contained in:
parent
6d4b91cf2b
commit
549fcba40f
2 changed files with 2 additions and 2 deletions
|
@ -146,7 +146,7 @@ void OpusEncoder::initEncoder()
|
||||||
|
|
||||||
// create some opus pseudo header to let the decoder know about the sample format
|
// create some opus pseudo header to let the decoder know about the sample format
|
||||||
headerChunk_->payloadSize = 12;
|
headerChunk_->payloadSize = 12;
|
||||||
headerChunk_->payload = (char*)malloc(headerChunk_->payloadSize);
|
headerChunk_->payload = (char*)realloc(headerChunk_->payload, headerChunk_->payloadSize);
|
||||||
char* payload = headerChunk_->payload;
|
char* payload = headerChunk_->payload;
|
||||||
assign(payload, SWAP_32(ID_OPUS));
|
assign(payload, SWAP_32(ID_OPUS));
|
||||||
assign(payload + 4, SWAP_32(sampleFormat_.rate));
|
assign(payload + 4, SWAP_32(sampleFormat_.rate));
|
||||||
|
|
|
@ -57,7 +57,7 @@ void PcmEncoder::encode(const msg::PcmChunk* chunk)
|
||||||
void PcmEncoder::initEncoder()
|
void PcmEncoder::initEncoder()
|
||||||
{
|
{
|
||||||
headerChunk_->payloadSize = 44;
|
headerChunk_->payloadSize = 44;
|
||||||
headerChunk_->payload = (char*)malloc(headerChunk_->payloadSize);
|
headerChunk_->payload = (char*)realloc(headerChunk_->payload, headerChunk_->payloadSize);
|
||||||
char* payload = headerChunk_->payload;
|
char* payload = headerChunk_->payload;
|
||||||
assign(payload, SWAP_32(ID_RIFF));
|
assign(payload, SWAP_32(ID_RIFF));
|
||||||
assign(payload + 4, SWAP_32(36));
|
assign(payload + 4, SWAP_32(36));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue