Allocate memory with proper length and deallocate the memory afterwards.

This commit is contained in:
Moritz Bunkus 2008-09-21 16:11:22 +00:00
parent 1f9efc5959
commit fe0524a11b

View File

@ -532,11 +532,11 @@ mpeg_ps_reader_c::new_stream_v_avc_or_mpeg_1_2(int id,
if (!parse_packet(id, timecode, new_length, full_length, aid))
continue;
memory_c new_buf((unsigned char *)safemalloc(length), 0, true);
if (io->read(new_buf.get(), new_length) != new_length)
memory_cptr new_buf = memory_c::alloc(new_length);
if (io->read(new_buf->get(), new_length) != new_length)
throw false;
buffer.add(new_buf.get(), new_length);
buffer.add(new_buf->get(), new_length);
}
} catch (...) {