changeset 794:93dbfe1f0cd0 trunk

[svn] - same sanity check on rarely executed part.
author yaz
date Wed, 07 Mar 2007 06:49:54 -0800
parents 98cdc39031f9
children ca6dca840074
files ChangeLog src/madplug/decoder.c
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Mar 07 06:16:04 2007 -0800
+++ b/ChangeLog	Wed Mar 07 06:49:54 2007 -0800
@@ -1,3 +1,11 @@
+2007-03-07 14:16:04 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [1684]
+  - add sanity check for open audio parameters.
+  
+  trunk/src/madplug/decoder.c |   12 +++++++++++-
+  1 file changed, 11 insertions(+), 1 deletion(-)
+
+
 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.
--- a/src/madplug/decoder.c	Wed Mar 07 06:16:04 2007 -0800
+++ b/src/madplug/decoder.c	Wed Mar 07 06:49:54 2007 -0800
@@ -597,14 +597,24 @@
                 info->freq = frame.header.samplerate;
                 info->channels = MAD_NCHANNELS(&frame.header);
                 info->playback->output->close_audio();
+
+                // 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;
                     info->playback->eof = 1;
                     g_mutex_unlock(pb_mutex);
-                    audmad_error("failed to re-open audio output: %s",
+                    g_message("failed to re-open audio output: %s",
                                   info->playback->output->description);
+                    return NULL;
                 }
             }
             if (!info->playback->playing)