Avoid a memleak.

This commit is contained in:
Moritz Bunkus 2007-01-04 13:42:44 +00:00
parent 99e07e1cc2
commit 33bd766c2c

View File

@ -41,25 +41,24 @@ using namespace mpeg4::p10;
int
avc_es_reader_c::probe_file(mm_io_c *io,
int64_t size) {
unsigned char *buf;
int num_read;
if (size < PROBESIZE)
return 0;
try {
buf = (unsigned char *)safemalloc(READ_SIZE);
io->setFilePointer(0, seek_beginning);
num_read = io->read(buf, READ_SIZE);
if (num_read < 4) {
safefree(buf);
if (size < PROBESIZE)
return 0;
}
memory_cptr buf(new memory_c((unsigned char *)safemalloc(READ_SIZE),
READ_SIZE));
int num_read;
io->setFilePointer(0, seek_beginning);
num_read = io->read(buf->get(), READ_SIZE);
io->setFilePointer(0, seek_beginning);
if (num_read < 4)
return 0;
avc_es_parser_c parser;
parser.set_nalu_size_length(4);
parser.enable_timecode_generation(40000000);
parser.add_bytes(buf, num_read);
parser.add_bytes(buf->get(), num_read);
return parser.headers_parsed();