Bug 169287

Summary: program reads uninited local variable
Product: [Fedora] Fedora Reporter: David Binderman <dcb314>
Component: qtAssignee: Than Ngo <than>
Status: CLOSED UPSTREAM QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-09-27 11:13:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Binderman 2005-09-26 16:29:28 UTC
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 Than Ngo 2005-09-26 17:09:55 UTC
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 17:46:59 UTC
>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 Than Ngo 2005-09-26 18:47:42 UTC
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 08:40:31 UTC
>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 Than Ngo 2005-09-27 09:35:44 UTC
yes, it's obviously that "error" is not initialised before using. Sorry i have
been blind!

Comment 6 Than Ngo 2005-09-27 11:13:47 UTC
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.