diff src/madplug/decoder.c @ 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
line wrap: on
line diff
--- 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;