changeset 793:98cdc39031f9 trunk

[svn] - add sanity check for open audio parameters.
author yaz
date Wed, 07 Mar 2007 06:16:04 -0800
parents 2b2313fc1ddc
children 93dbfe1f0cd0
files ChangeLog src/madplug/decoder.c
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 07 05:36:20 2007 -0800
+++ b/ChangeLog	Wed Mar 07 06:16:04 2007 -0800
@@ -1,3 +1,11 @@
+2007-03-07 13:36:20 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [1682]
+  - I was noticed vfs_fread check still causes problem. disable for now.
+  
+  trunk/src/madplug/decoder.c |    4 ++--
+  1 file changed, 2 insertions(+), 2 deletions(-)
+
+
 2007-03-07 13:08:55 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [1680]
   - only perform vfs fseek against info::infile if it is available.
--- a/src/madplug/decoder.c	Wed Mar 07 05:36:20 2007 -0800
+++ b/src/madplug/decoder.c	Wed Mar 07 06:16:04 2007 -0800
@@ -208,7 +208,9 @@
                              BUFFER_SIZE - remainder);
 
         if (len <= 0) {
-            g_message("scan_file: len <= 0! len = %d\n", len);
+#ifdef DEBUG
+            g_message("scan_file: len <= 0! len = %d", len);
+#endif
             break;
         }
 
@@ -411,6 +413,14 @@
 #ifdef DEBUG
     g_message("decode: fmt = %d freq = %d channels = %d", info->fmt, info->freq, info->channels);
 #endif
+    // sanity check.
+    if(info->fmt < FMT_U8 || info->fmt > FMT_S16_NE)
+        return NULL;
+    if(info->freq < 0) // not sure about maximum frequency. --yaz
+        return NULL;
+    if(info->channels < 1 || info->channels > 2)
+        return NULL;
+    
     if (!info->playback->output->open_audio(info->fmt, info->freq, info->channels)) {
         g_mutex_lock(pb_mutex);
         info->playback->error = TRUE;