changeset 1346:961f3f0aa2e8 trunk

[svn] - sanity checking prevents us from exploding when we encounter a file we don't support
author nenolod
date Wed, 28 Jun 2006 12:24:47 -0700
parents 19e6c1f1d509
children 8a874906535b
files ChangeLog Plugins/Input/aac/mp4ff/mp4ff.c Plugins/Input/aac/src/libmp4.c
diffstat 3 files changed, 33 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 28 11:59:29 2006 -0700
+++ b/ChangeLog	Wed Jun 28 12:24:47 2006 -0700
@@ -1,3 +1,12 @@
+2006-06-28 18:59:29 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [1602]
+  - cleanups
+  
+
+  Changes:        Modified:
+  +12 -57         trunk/Plugins/Input/aac/src/libmp4.c  
+
+
 2006-06-28 14:01:29 +0000  Tony Vroon <chainsaw@gentoo.org>
   revision [1600]
   Thanks to fluxinator this botched submission is now fixed.
--- a/Plugins/Input/aac/mp4ff/mp4ff.c	Wed Jun 28 11:59:29 2006 -0700
+++ b/Plugins/Input/aac/mp4ff/mp4ff.c	Wed Jun 28 12:24:47 2006 -0700
@@ -177,7 +177,7 @@
 int32_t mp4ff_get_decoder_config(const mp4ff_t *f, const int32_t track,
                                  uint8_t** ppBuf, uint32_t* pBufSize)
 {
-    if (track >= f->total_tracks)
+    if (track < 0 || track >= f->total_tracks)
     {
         *ppBuf = NULL;
         *pBufSize = 0;
@@ -204,7 +204,10 @@
 
 int32_t mp4ff_get_track_type(const mp4ff_t *f, const int track)
 {
-	return f->track[track]->type;
+    if (track < 0)
+	return -1;
+
+    return f->track[track]->type;
 }
 
 int32_t mp4ff_total_tracks(const mp4ff_t *f)
@@ -214,22 +217,34 @@
 
 int32_t mp4ff_time_scale(const mp4ff_t *f, const int32_t track)
 {
+    if (track < 0)
+	return -1;
+
     return f->track[track]->timeScale;
 }
 
 uint32_t mp4ff_get_avg_bitrate(const mp4ff_t *f, const int32_t track)
 {
+    if (track < 0)
+	return -1;
+
 	return f->track[track]->avgBitrate;
 }
 
 uint32_t mp4ff_get_max_bitrate(const mp4ff_t *f, const int32_t track)
 {
+    if (track < 0)
+	return -1;
+
 	return f->track[track]->maxBitrate;
 }
 
 int64_t mp4ff_get_track_duration(const mp4ff_t *f, const int32_t track)
 {
-	return f->track[track]->duration;
+    if (track < 0)
+	return -1;
+
+    return f->track[track]->duration;
 }
 
 int64_t mp4ff_get_track_duration_use_offsets(const mp4ff_t *f, const int32_t track)
@@ -250,6 +265,9 @@
     int32_t i;
     int32_t total = 0;
 
+    if (track < 0)
+	return -1;
+
     for (i = 0; i < f->track[track]->stts_entry_count; i++)
     {
         total += f->track[track]->stts_sample_count[i];
--- a/Plugins/Input/aac/src/libmp4.c	Wed Jun 28 11:59:29 2006 -0700
+++ b/Plugins/Input/aac/src/libmp4.c	Wed Jun 28 12:24:47 2006 -0700
@@ -250,6 +250,9 @@
 		guint bufferSize = 0;
 		faacDecHandle decoder;
 
+		if (mp4track == -1)
+			return NULL;
+
 		decoder = faacDecOpen();
 		mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize);