Uninitialized local variable
Brought to you by:
sobukus
Hi
src/libmpg123/layer3.c(415): warning C4700: uninitialized local variable 'needbits' used
src/libmpg123/format.c(418): warning C4700: uninitialized local variable 'ratei' used
fix:
+++ /src/libmpg123/layer3.c
@@ -411,7 +411,7 @@
const int *tab = tabs[fr->lsf];
{ /* First ensure we got enough bits available. */
- unsigned int needbits;
+ unsigned int needbits = 0;
needbits += tab[1]; /* main_data_begin */
needbits += stereo == 1 ? tab[2] : tab[3]; /* private */
if(!fr->lsf)
+++ /src/libmpg123/format.c
@@ -404,6 +404,7 @@
int attribute_align_arg mpg123_fmt(mpg123_pars *mp, long rate, int channels, int encodings)
{
int ie, ic, ratei, r1, r2;
+ ratei = 0;
int ch[2] = {0, 1};
if(mp == NULL) return MPG123_BAD_PARS;
if(!(channels & (MPG123_MONO|MPG123_STEREO))) return MPG123_BAD_CHANNEL;
original source from svn://scm.orgis.org/mpg123/trunk
Thanks for finding those errors in the svn repo before a release. The correct fix for the ratei issue is
-r2 = ratei+1
+r2 = r1+1
later in the function. The premature use of ratei is the error. Stupid mistake on my part.
I fixed the code in svn. The nightly snapshot will contain the update tomorrow.
Thanks! This is great!