[FFmpeg-cvslog] mp3enc: fix "warning: best_bitrate_idx may be used uninitialized in this function"

Michael Niedermayer git at videolan.org
Sat Feb 25 03:03:04 CET 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sat Feb 25 02:17:37 2012 +0100| [4dbdd3ec6f4a5c7d8e4f3cfe0f564bb14a77503c] | committer: Michael Niedermayer

mp3enc: fix "warning: best_bitrate_idx may be used uninitialized in this function"

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4dbdd3ec6f4a5c7d8e4f3cfe0f564bb14a77503c
---

 libavformat/mp3enc.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 8d82452..3bbc3e8 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -35,6 +35,7 @@
 #include "libavcodec/mpegaudiodecheader.h"
 #include "libavformat/avio_internal.h"
 #include "libavutil/dict.h"
+#include "libavutil/avassert.h"
 
 static int id3v1_set_string(AVFormatContext *s, const char *key,
                             uint8_t *buf, int buf_size)
@@ -157,7 +158,7 @@ static int mp3_write_xing(AVFormatContext *s)
     AVCodecContext   *codec = s->streams[0]->codec;
     MP3Context       *mp3 = s->priv_data;
     int              bitrate_idx;
-    int              best_bitrate_idx;
+    int              best_bitrate_idx = -1;
     int              best_bitrate_error= INT_MAX;
     int64_t          xing_offset;
     int32_t          header, mask;
@@ -196,6 +197,7 @@ static int mp3_write_xing(AVFormatContext *s)
             best_bitrate_idx  = bitrate_idx;
         }
     }
+    av_assert0(best_bitrate_idx >= 0);
 
     for (bitrate_idx= best_bitrate_idx;; bitrate_idx++) {
         if (15 == bitrate_idx)



More information about the ffmpeg-cvslog mailing list