Closed Bug 204503 Opened 22 years ago Closed 22 years ago

Uninitialized variable in mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp

Categories

(Core :: Networking, defect)

x86
Linux
defect
Not set
trivial

Tracking

()

VERIFIED FIXED
mozilla1.6beta

People

(Reporter: tenthumbs, Assigned: darin.moz)

Details

Attachments

(2 files)

Gcc says: nsJARChannel.cpp:465: warning: `nsresult rv' might be used \ uninitialized in this function The relevant code is: 488 if (ext) { 489 nsIMIMEService *mimeServ = gJarHandler->MimeService(); 490 if (mimeServ) { 491 nsXPIDLCString mimeType; 492 rv = mimeServ->GetTypeFromExtension(ext, getter_Copies(mimeType)); 493 if (NS_SUCCEEDED(rv)) 494 mContentType = mimeType; 495 } 496 } 497 else 498 rv = NS_ERROR_NOT_AVAILABLE; 499 500 if (NS_FAILED(rv) || mContentType.IsEmpty()) 501 mContentType = NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE); Not that if (ext && !mimeServ) then rv is not set.
That should say: Note that if (ext && !mimeServ) the rv is not set.
pushing out since not critical that we run without a mime service...
Severity: normal → trivial
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.5alpha
-> suresh
Assignee: darin → suresh
Status: ASSIGNED → NEW
Status: NEW → ASSIGNED
Target Milestone: mozilla1.5alpha → mozilla1.5beta
Make sure that rv is initialised ok, and change flow in function so that it is more clear that mContentType is always set: if (mContentType is empty) { // Try to set the mContentType // If still empty or error set mContentType to 'UNKNOWN_CONTENT_TYPE' } return mContentType This also saves a couple of code bytes
Attachment #135174 - Flags: review?(darin)
if (mContentType is empty) { // Try to set the mContentType if (mContent is still empty) set mContentType to 'UNKNOWN_CONTENT_TYPE' } return mContentType
Attachment #135174 - Attachment is obsolete: true
Attachment #135174 - Attachment is obsolete: false
Attachment #135174 - Flags: review?(darin)
Attachment #135175 - Flags: review?(darin)
Comment on attachment 135175 [details] [diff] [review] Even better, use only rv where needed r=darin
Attachment #135175 - Flags: review?(darin) → review+
-> me (for checkin)
Assignee: suresh → darin
Status: ASSIGNED → NEW
Target Milestone: mozilla1.5beta → mozilla1.6beta
fixed-on-trunk
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: