Closed Bug 1496364 Opened Last year Closed Last year

variable 'jobLevel' is used uninitialized whenever 'if' condition is false

Categories

(Core :: Security: Process Sandboxing, defect, P1)

x86_64
Windows
defect

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: jya, Assigned: cmartin)

Details

(Whiteboard: sb+)

Attachments

(1 file)

a few compilation warnings in this code, which makes for noisy builds.

0:30.96 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(390,14):  warning: variable 'jobLevel' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
 0:30.96   } else if (aSandboxLevel == 1) {
 0:30.97              ^~~~~~~~~~~~~~~~~~
 0:30.97 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(415,53):  note: uninitialized use occurs here
 0:30.97   sandbox::ResultCode result = SetJobLevel(mPolicy, jobLevel, uiExceptions);
 0:30.97                                                     ^~~~~~~~
 0:30.97 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(390,10):  note: remove the 'if' if its condition is always true
 0:30.97   } else if (aSandboxLevel == 1) {
 0:30.97          ^~~~~~~~~~~~~~~~~~~~~~~~
 0:30.97 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(361,3):  note: variable 'jobLevel' is declared here
 0:30.97   sandbox::JobLevel jobLevel;
 0:30.97   ^
 0:30.97 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(586,14):  warning: variable 'jobLevel' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
 0:30.97   } else if (aSandboxLevel == 1) {
 0:30.97              ^~~~~~~~~~~~~~~~~~
 0:30.97 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(593,53):  note: uninitialized use occurs here
 0:30.98   sandbox::ResultCode result = SetJobLevel(mPolicy, jobLevel,
 0:30.98                                                     ^~~~~~~~
 0:30.98 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(586,10):  note: remove the 'if' if its condition is always true
 0:30.98   } else if (aSandboxLevel == 1) {
 0:30.98          ^~~~~~~~~~~~~~~~~~~~~~~~
 0:30.98 c:/Users/jyavenard/Work/Mozilla/mozilla-central/security/sandbox/win/src/sandboxbroker/sandboxBroker.cpp(572,3):  note: variable 'jobLevel' is declared here
 0:30.98   sandbox::JobLevel jobLevel;
 0:30.98   ^
 0:31.17 netwerk/protocol/viewsource
 0:31.46 2 warnings generated.
Assignee: nobody → cmartin
Priority: -- → P1
Whiteboard: sb+
The compiler warns that jobLevel is uninitialized if none of the if-else
conditions are true. Simply replacing the leading assert with a
"else crash" tells the compiler that case will never actually happen.
Attachment #9017494 - Flags: checkin?(davidp99)
Attachment #9017494 - Flags: checkin?(davidp99)
Pushed by csabou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5441249fe314
Minor refactor to stop uninitialized variable warning r=handyman
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/5441249fe314
Status: NEW → RESOLVED
Closed: Last year
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.