Closed Bug 189922 Opened 23 years ago Closed 23 years ago

Uninitialized variable in xpcom/typelib/xpt/src/xpt_struct

Categories

(Core :: XPConnect, defect)

x86
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: tenthumbs, Assigned: dbradley)

Details

Attachments

(1 file)

I'm not sure about the component so feel free to change it. In xpcom/typelib/xpt/src/xpt_struct.c gcc thows this warning. xpt_struct.c:245: warning: `header' might be used uninitialized in this function 240 XPT_PUBLIC_API(PRBool) 241 XPT_DoHeader(XPTArena *arena, XPTCursor *cursor, XPTHeader **headerp) 242 { 243 const int HEADER_SIZE = 24; 244 XPTMode mode = cursor->state->mode; 245 XPTHeader * header; 246 PRUint32 ide_offset; 247 int i; 248 XPTAnnotation *ann, *next, **annp; 249 250 if (!XPT_DoHeaderPrologue(arena, cursor, headerp, &ide_offset)) 251 return PR_FALSE; 252 /* 253 * Make sure the file length reported in the header is the same size as 254 * as our buffer unless it is zero (not set) 255 */ 256 if (mode == XPT_DECODE && ((*headerp)->file_length != 0 && 257 cursor->state->pool->allocated < (*headerp)->file_length)) { 258 fputs("libxpt: File length in header does not match actual length. File may be corrupt\n", 259 stderr); 260 goto error; 261 } 262 263 header = *headerp; 313 /* XXX need to free child data sometimes! */ 314 XPT_ERROR_HANDLE(arena, header); 315 } As you can see the error exit at line 260, which goes to line 314 where header may well be used, occurs before header is set at line 263. Presumably you can just initialize heder to NULL or maybe just move line 263 before line 256.
Thanks for catching this, this looks to be the result of my adding the file corruption checking logic.
Attachment #112182 - Flags: superreview?(jst)
Attachment #112182 - Flags: review+
Comment on attachment 112182 [details] [diff] [review] Moves the assignment of header up before the file length check sr=jst
Attachment #112182 - Flags: superreview?(jst) → superreview+
Fix checked in
Status: NEW → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
Checkin verified -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: