Bug 169287 - program reads uninited local variable
program reads uninited local variable
Status: CLOSED UPSTREAM
Product: Fedora
Classification: Fedora
Component: qt (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Ngo Than
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-09-26 12:29 EDT by David Binderman
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-09-27 07:13:47 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description David Binderman 2005-09-26 12:29:28 EDT
Description of problem:
I just tried to compile Fedora development package qt-3.3.5-2
with the extra compiler flag -Wall.

The compiler said

3rdparty/opentype/ftxgdef.c:1084: warning: 'error' is used uninitialized in this
function

The source code is

    /* we don't accept glyphs covered in `GlyphClassDef' */

    if ( !error )
      return TTO_Err_Not_Covered;

Suggest initialise local variable "error" before first use.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:
Comment 1 Ngo Than 2005-09-26 13:09:55 EDT
which gcc version have you used here? I cannot reproduce it here with
gcc-4.0.1-14. Taken a look at the source, the error is initialized before using

 if ( gdef->GlyphClassDef.loaded )
    {
    error = Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index );
    if ( error && error != TTO_Err_Not_Covered )
      return error;
    }
    else
    {
        klass = 0;
        index = 0;
    }
    /* we don't accept glyphs covered in `GlyphClassDef' */

    if ( !error )
      return TTO_Err_Not_Covered;
Comment 2 David Binderman 2005-09-26 13:46:59 EDT
>which gcc version have you used here?

The one that is standard in FC4. I think it is gcc 4.0.0

>I cannot reproduce it here

The error is obvious by visual inspection. Please try again.

>the error is initialized before using

Local variable "error" is only initialise under some, not
all, execution paths.

Suggest initialise "error" on _all_ execution paths.
 
Comment 3 Ngo Than 2005-09-26 14:47:42 EDT
Hm, by visual inspection the local variable "error" is always initialised here if
condition gdef->GlyphClassDef.loaded is true!

 if ( gdef->GlyphClassDef.loaded )
    {
    error = Get_Class( &gdef->GlyphClassDef, glyphID, &klass, &index );

Comment 4 David Binderman 2005-09-27 04:40:31 EDT
>local variable "error" is always initialised

What happens if gdef->GlyphClassDef.loaded is false ?

I suggest again to have another look. 

Both I and the compiler think there are execution paths where "error"
is not initialised.
Comment 5 Ngo Than 2005-09-27 05:35:44 EDT
yes, it's obviously that "error" is not initialised before using. Sorry i have
been blind!
Comment 6 Ngo Than 2005-09-27 07:13:47 EDT
ok, it seems that this 3dparty code is not used by default. I have already
sent the fix to trolltech for including in next upstream release. Thanks for
your report.

Note You need to log in before you can comment on or make changes to this bug.