Possible operator precedence error in ots_gdef_parse()

RESOLVED FIXED

Status

()

Core
Graphics
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: Dolske, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

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

(Reporter)

Description

5 years ago
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));
(Reporter)

Updated

5 years ago
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
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.