Mercurial > mplayer.hg
changeset 5303:534f16f50c17
10l fix memory allocation
author | atmos4 |
---|---|
date | Sun, 24 Mar 2002 03:07:18 +0000 |
parents | 6dc0ac26eb0e |
children | 6175c9cfab11 |
files | libmpdemux/demux_mov.c libmpdemux/parse_mp4.c |
diffstat | 2 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_mov.c Sun Mar 24 02:38:20 2002 +0000 +++ b/libmpdemux/demux_mov.c Sun Mar 24 03:07:18 2002 +0000 @@ -707,7 +707,7 @@ mp_msg(MSGT_DEMUX, MSGL_INFO, "MOV: Found MPEG4 audio Elementary Stream Descriptor atom (%d)!\n", atom_len); if(atom_len >= 8) { esds_t *esds = (esds_t *)malloc(sizeof(esds_t)); - if(!mp4_parse_esds(&trak->stdata[36], atom_len-8, esds)) { + if(esds && !mp4_parse_esds(&trak->stdata[36], atom_len-8, esds)) { sh->i_bps = esds->avgBitrate/8; @@ -716,7 +716,11 @@ sh->codecdata = (unsigned char *)malloc(sh->codecdata_len); memcpy(sh->codecdata, esds->decoderConfig, sh->codecdata_len); } - free(esds); + if(esds) { + if(esds->decoderConfig) + free(esds->decoderConfig); + free(esds); + } #if 0 { FILE* f=fopen("esds.dat","wb"); fwrite(&trak->stdata[36],atom_len-8,1,f);
--- a/libmpdemux/parse_mp4.c Sun Mar 24 02:38:20 2002 +0000 +++ b/libmpdemux/parse_mp4.c Sun Mar 24 03:07:18 2002 +0000 @@ -13,6 +13,7 @@ #include "stream.h" #define MP4_DL MSGL_V +#define freereturn(a,b) free(a); return b int mp4_read_descr_len(stream_t *s) { uint8_t b; @@ -45,7 +46,7 @@ if (tag == MP4ESDescrTag) { /* read length */ if ((len = mp4_read_descr_len(s)) < 5 + 15) { - return 1; + freereturn(s,1); } esds->ESId = stream_read_word(s); esds->streamPriority = stream_read_char(s); @@ -65,12 +66,12 @@ /* get and verify DecoderConfigDescrTab */ if (stream_read_char(s) != MP4DecConfigDescrTag) { - return 1; + freereturn(s,1); } /* read length */ if ((len = mp4_read_descr_len(s)) < 15) { - return 1; + freereturn(s,1); } esds->objectTypeId = stream_read_char(s); @@ -91,13 +92,12 @@ /* get and verify DecSpecificInfoTag */ if (stream_read_char(s) != MP4DecSpecificDescrTag) { - return 1; + freereturn(s,1); } /* read length */ esds->decoderConfigLen = len = mp4_read_descr_len(s); - free(esds->decoderConfig); esds->decoderConfig = malloc(esds->decoderConfigLen); if (esds->decoderConfig) { stream_read(s, esds->decoderConfig, esds->decoderConfigLen); @@ -108,7 +108,10 @@ "ESDS MPEG4 Decoder Specific Descriptor (%dBytes)\n", len); /* will skip the remainder of the atom */ - return 0; + freereturn(s,0); } +#undef freereturn +#undef MP4_DL +