# HG changeset patch # User reimar # Date 1313692373 0 # Node ID 50489783444dc9a09f08e8587db89a56c09173c8 # Parent 02f1dc5c8bda4310f63080d9cb49de97279eea20 Simply drop packets for which new_demux_packet allocation fails. This allows to play some corrupted files instead of crashing. diff -r 02f1dc5c8bda -r 50489783444d libmpdemux/demuxer.c --- a/libmpdemux/demuxer.c Mon Aug 15 21:28:19 2011 +0000 +++ b/libmpdemux/demuxer.c Thu Aug 18 18:32:53 2011 +0000 @@ -593,6 +593,7 @@ ds_add_packet_internal(ds, dp); } else if (parsed_len) { demux_packet_t *dp2 = new_demux_packet(parsed_len); + if (!dp2) return; dp2->pos = dp->pos; dp2->pts = dp->pts; // should be parser->pts but that works badly memcpy(dp2->buffer, parsed_start, parsed_len); @@ -608,6 +609,7 @@ double pts, off_t pos, int flags) { demux_packet_t *dp = new_demux_packet(len); + if (!dp) return; len = stream_read(stream, dp->buffer, len); resize_demux_packet(dp, len); dp->pts = pts; @@ -713,6 +715,7 @@ ds_parse(ds->sh, &parsed_start, &parsed_len, MP_NOPTS_VALUE, 0); if (parsed_len) { demux_packet_t *dp2 = new_demux_packet(parsed_len); + if (!dp2) continue; dp2->pts = MP_NOPTS_VALUE; memcpy(dp2->buffer, parsed_start, parsed_len); ds_add_packet_internal(ds, dp2);