Closed Bug 188640 Opened 17 years ago Closed 17 years ago

nsEmbedGlobalHistory.cpp: enumWriteEntryIfUnwritten can test NS_SUCCEEDED(rv) on an uninitialized rv!

Categories

(Core Graveyard :: Embedding: APIs, defect)

x86
Linux
defect
Not set

Tracking

(Not tracked)

VERIFIED FIXED

People

(Reporter: mozilla-bugs, Assigned: adamlock)

References

Details

After embedding/lite became a part of the build, a new "uninitialized" warning
appeared on brad TBox:

+embedding/lite/nsEmbedGlobalHistory.cpp:538
+ `nsresult rv' might be used uninitialized in this function

The code in question (end of enumWriteEntryIfUnwritten function) looks as follows:

   nsresult rv;
   if (!entry->GetIsWritten())
     rv = writeEntry(outStm, stringKey, entry);
     
   return NS_SUCCEEDED(rv) ? PR_TRUE : PR_FALSE;

Indeed, when the "if" condition is false, the function will return a random
value (depending on memory contents in an uninitialized nsresult).

P.S. See also bugs 59652 and 179819. Bug 59652 is the meta-bug tracking the
fight against these (potentially very nasty) warnings and bug 179819 wants such
warnings turned into compilation errors.
Fixed.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
V, the warning has disappeared from TBox
Status: RESOLVED → VERIFIED
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.