Skip to content

Commit

Permalink
Fix a couple memory leaks. cppcheck.
Browse files Browse the repository at this point in the history
[cherry-picked from ca59bf3]
  • Loading branch information
daniel-kristjansson authored and jyavenard committed Feb 11, 2012
1 parent 231ed7a commit b5a557f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mythtv/libs/libmyth/audiooutputdigitalencoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,18 @@ size_t AudioOutputDigitalEncoder::Encode(void *buf, int len, AudioFormat format)
QString("low mem, reallocating in buffer from %1 to %2")
.arg(in_size)
.arg(required_len));
if (!(in = (inbuf_t *)realloc(in, in_size, required_len)))
inbuf_t *tmp = reinterpret_cast<inbuf_t*>
(realloc(in, in_size, required_len));
if (!tmp)
{
free(in);
in = NULL;
in_size = 0;
VERBOSE(VB_AUDIO, LOC_ERR +
"AC-3 encode error, insufficient memory");
return outlen;
}
in = tmp;
in_size = required_len;
}
if (format != FORMAT_S16)
Expand Down Expand Up @@ -224,13 +229,18 @@ size_t AudioOutputDigitalEncoder::Encode(void *buf, int len, AudioFormat format)
QString("low mem, reallocating out buffer from %1 to %2")
.arg(out_size)
.arg(required_len));
if (!(out = (outbuf_t *)realloc(out, out_size, required_len)))
outbuf_t *tmp = reinterpret_cast<outbuf_t*>
(realloc(out, out_size, required_len));
if (!tmp)
{
free(out);
out = NULL;
out_size = 0;
VERBOSE(VB_AUDIO, LOC_ERR +
"AC-3 encode error, insufficient memory");
return outlen;
}
out = tmp;
out_size = required_len;
}
int data_size = 0;
Expand Down

0 comments on commit b5a557f

Please sign in to comment.