summaryrefslogtreecommitdiffstats
path: root/libmpdemux/parse_mp4.c
diff options
context:
space:
mode:
authoratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-03-24 03:07:18 +0000
committeratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-03-24 03:07:18 +0000
commit582d209217facc18cdc3b179a9b4bbf22a94828d (patch)
tree77052d202dbb3a415a36a4dc545f236a452e9d13 /libmpdemux/parse_mp4.c
parenta316f53a830e8d9b22b50ef21bc0d6543f5bb449 (diff)
downloadmpv-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/parse_mp4.c')
-rw-r--r--libmpdemux/parse_mp4.c15
1 files changed, 9 insertions, 6 deletions
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
+