Menu ▾ ▴

#258 Uninitialized local variable

svn
closed-fixed
nobody
None
5
2020-05-16
2017-12-31
chipmunk-sm
No

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

Discussion

  • Thomas Orgis

    Thomas Orgis - 2018-01-01

    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.

     
  • chipmunk-sm

    chipmunk-sm - 2018-01-01

    Thanks! This is great!

     
  • Thomas Orgis

    Thomas Orgis - 2020-05-16
    • status: open --> closed-fixed
     

Log in to post a comment.