sagpant / stepmania

0 stars 1 forks source link

Potential issue in extern/newvorbis/lib/vorbisfile.c: Unchecked return from initialization function #5

Open monocle-ai opened 4 years ago

monocle-ai commented 4 years ago

What is a Conditionally Uninitialized Variable? The return value of a function that is potentially used to initialize a local variable is not checked. Therefore, reading the local variable may result in undefined behavior.

3 instances of this defect were found in the following locations:


Instance 1 File : extern/newvorbis/lib/vorbisfile.c Enclosing Function : ov_crosslap Function : vorbis_synthesis_lapout https://github.com/sagpant/stepmania/blob/5dad6a1c9a1caba66ebc1aa0feab9bc920399455/extern/newvorbis/lib/vorbisfile.c#L2295 Issue in: pcm

Code extract:

  /* have a lapping buffer from vf1; now to splice it into the lapping
     buffer of vf2 */
  /* consolidate and expose the buffer. */
  vorbis_synthesis_lapout(&vf2->vd,&pcm); <------ HERE

#if 0

How can I fix it? Correct reference usage found in extern/newvorbis/lib/vorbisfile.c at line 2240. https://github.com/sagpant/stepmania/blob/5dad6a1c9a1caba66ebc1aa0feab9bc920399455/extern/newvorbis/lib/vorbisfile.c#L2240 Code extract:

    /* failed to get lapping data from normal decode; pry it from the
       postextrapolation buffering, or the second half of the MDCT
       from the last packet */
    int samples=vorbis_synthesis_lapout(&vf->vd,&pcm); <------ HERE
    if(samples==0){
      for(i=0;i<vi->channels;i++)

Instance 2 File : extern/newvorbis/lib/vorbisfile.c Enclosing Function : _ov_64_seek_lap Function : vorbis_synthesis_lapout https://github.com/sagpant/stepmania/blob/5dad6a1c9a1caba66ebc1aa0feab9bc920399455/extern/newvorbis/lib/vorbisfile.c#L2349 Issue in: pcm

Code extract:

  w2=vorbis_window(&vf->vd,0);

  /* consolidate and expose the buffer. */
  vorbis_synthesis_lapout(&vf->vd,&pcm); <------ HERE

  /* splice */

How can I fix it? Correct reference usage found in extern/newvorbis/lib/vorbisfile.c at line 2240. https://github.com/sagpant/stepmania/blob/5dad6a1c9a1caba66ebc1aa0feab9bc920399455/extern/newvorbis/lib/vorbisfile.c#L2240 Code extract:

    /* failed to get lapping data from normal decode; pry it from the
       postextrapolation buffering, or the second half of the MDCT
       from the last packet */
    int samples=vorbis_synthesis_lapout(&vf->vd,&pcm); <------ HERE
    if(samples==0){
      for(i=0;i<vi->channels;i++)

Instance 3 File : extern/newvorbis/lib/vorbisfile.c Enclosing Function : _ov_d_seek_lap Function : vorbis_synthesis_lapout https://github.com/sagpant/stepmania/blob/5dad6a1c9a1caba66ebc1aa0feab9bc920399455/extern/newvorbis/lib/vorbisfile.c#L2410 Issue in: pcm

Code extract:

  w2=vorbis_window(&vf->vd,0);

  /* consolidate and expose the buffer. */
  vorbis_synthesis_lapout(&vf->vd,&pcm); <------ HERE

  /* splice */

How can I fix it? Correct reference usage found in extern/newvorbis/lib/vorbisfile.c at line 2240. https://github.com/sagpant/stepmania/blob/5dad6a1c9a1caba66ebc1aa0feab9bc920399455/extern/newvorbis/lib/vorbisfile.c#L2240 Code extract:

    /* failed to get lapping data from normal decode; pry it from the
       postextrapolation buffering, or the second half of the MDCT
       from the last packet */
    int samples=vorbis_synthesis_lapout(&vf->vd,&pcm); <------ HERE
    if(samples==0){
      for(i=0;i<vi->channels;i++)
siva-msft commented 4 years ago

lgtm