Closed Bug 710988 Opened 13 years ago Closed 13 years ago

Possible operator precedence error in ots_gdef_parse()

Categories

(Core :: Graphics, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Dolske, Unassigned)

References

Details

(Whiteboard: [pvs-studio][good first bug][lang=c++])

From http://www.viva64.com/en/a/0078/,
5th section in http://www.viva64.com/external-pictures/txt/mozilla-test.txt

V502 Perhaps the '?:' operator works in a different way than it was expected. The '?:' operator has a lower priority than the '+' operator.
gdef.cc 291

bool ots_gdef_parse(...) {
  ...
  const unsigned gdef_header_end = static_cast<unsigned>(8) +
    gdef->version_2 ? static_cast<unsigned>(2) : static_cast<unsigned>(0);
  ...
}

I think there could be written like this.
const unsigned gdef_header_end = static_cast<unsigned>(8) +
  (gdef->version_2 ? static_cast<unsigned>(2) : static_cast<unsigned>(0));
Blocks: 710966
Whiteboard: [pvs-studio] → [pvs-studio][good first bug][lang=c++]
This bug is no longer present on trunk. The fragment in question has been restructured (upstream in OTS rev.66) and does not have this problem. The fix was imported into Gecko as part of bug 699420.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.