diff options
author | atmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-03-24 03:07:18 +0000 |
---|---|---|
committer | atmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-03-24 03:07:18 +0000 |
commit | 582d209217facc18cdc3b179a9b4bbf22a94828d (patch) | |
tree | 77052d202dbb3a415a36a4dc545f236a452e9d13 /libmpdemux | |
parent | a316f53a830e8d9b22b50ef21bc0d6543f5bb449 (diff) | |
download | mpv-582d209217facc18cdc3b179a9b4bbf22a94828d.tar.bz2 mpv-582d209217facc18cdc3b179a9b4bbf22a94828d.tar.xz |
10l fix memory allocation
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5304 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_mov.c | 8 | ||||
-rw-r--r-- | libmpdemux/parse_mp4.c | 15 |
2 files changed, 15 insertions, 8 deletions
diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c index d33547f4f5..9b3e3278fb 100644 --- a/libmpdemux/demux_mov.c +++ b/libmpdemux/demux_mov.c @@ -707,7 +707,7 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak 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 @@ static void lschunks(demuxer_t* demuxer,int level,off_t endpos,mov_track_t* trak 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); diff --git a/libmpdemux/parse_mp4.c b/libmpdemux/parse_mp4.c index e17703e6d5..512496984c 100644 --- a/libmpdemux/parse_mp4.c +++ b/libmpdemux/parse_mp4.c @@ -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 @@ int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds) { 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 @@ int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds) { /* 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 @@ int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds) { /* 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 @@ int mp4_parse_esds(unsigned char *data, int datalen, esds_t *esds) { "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 + |