Closed
Bug 806578
Opened 12 years ago
Closed 12 years ago
nsPresContext::GetFontPrefsForLang() uses uninitialized |nsresult rv| value
Categories
(Core :: Layout, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 813705
People
(Reporter: dholbert, Unassigned)
References
(Blocks 1 open bug, )
Details
Just noticed this legitimate (and verbose) clang output, when compiling nsPresContext.cpp:
{
../../../../layout/base/nsPresContext.cpp:421:7: warning: variable 'rv' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
if (aLanguage && mLangService) {
^~~~~~~~~~~~~~~~~~~~~~~~~
../../../../layout/base/nsPresContext.cpp:424:17: note: uninitialized use occurs here
if (NS_FAILED(rv) || !langGroupAtom) {
~~~~~~~~~~^~~
../../dist/include/nsError.h:156:67: note: expanded from macro 'NS_FAILED'
#define NS_FAILED(_nsresult) ((bool)NS_UNLIKELY(NS_FAILED_impl(_nsresult)))
^
../../dist/include/nscore.h:385:46: note: expanded from macro 'NS_UNLIKELY'
#define NS_UNLIKELY(x) (__builtin_expect(!!(x), 0))
^
../../../../layout/base/nsPresContext.cpp:421:3: note: remove the 'if' if its condition is always true
if (aLanguage && mLangService) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../layout/base/nsPresContext.cpp:421:7: warning: variable 'rv' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
if (aLanguage && mLangService) {
^~~~~~~~~
../../../../layout/base/nsPresContext.cpp:424:17: note: uninitialized use occurs here
if (NS_FAILED(rv) || !langGroupAtom) {
~~~~~~~~~~^~~
../../dist/include/nsError.h:156:67: note: expanded from macro 'NS_FAILED'
#define NS_FAILED(_nsresult) ((bool)NS_UNLIKELY(NS_FAILED_impl(_nsresult)))
^
../../dist/include/nscore.h:385:46: note: expanded from macro 'NS_UNLIKELY'
#define NS_UNLIKELY(x) (__builtin_expect(!!(x), 0))
^
../../../../layout/base/nsPresContext.cpp:421:7: note: remove the '&&' if its condition is always true
if (aLanguage && mLangService) {
^~~~~~~~~~~~
../../../../layout/base/nsPresContext.cpp:416:3: note: variable 'rv' is declared here
nsresult rv;
^
2 warnings generated.
}
from e.g. this opt OS X 10.7 tinderbox build log:
https://tbpl.mozilla.org/php/getParsedLog.php?id=16497853&tree=Firefox
Relevant code:
> 416 nsresult rv;
> 417 nsIAtom *langGroupAtom = nullptr;
[...]
> 421 if (aLanguage && mLangService) {
> 422 langGroupAtom = mLangService->GetLanguageGroup(aLanguage, &rv);
> 423 }
> 424 if (NS_FAILED(rv) || !langGroupAtom) {
> 425 langGroupAtom = nsGkAtoms::x_western; // Assume x-western is safe...
> 426 }
If we don't enter the first clause, then we won't initialize |rv|, and the second clause's "if" condition is bogus. Maybe we want to initialize |rv| to NS_ERROR_FAILURE? Or we could just reverse the condition, since if langGroupAtom is non-null, then rv has presumably been set.
(Looks like this chunk of code was added in bug 416581 "part 2" -- marking as dependent on that bug.)
Reporter | ||
Updated•12 years ago
|
OS: Linux → Mac OS X
Reporter | ||
Comment 1•12 years ago
|
||
Nice, jdm just landed a fix for this over on bug 813705.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•