Closed Bug 385259 Opened 18 years ago Closed 18 years ago

nsSelection.cpp relies on undefined behavior

Categories

(Core :: Layout, defect)

x86
Linux
defect
Not set
minor

Tracking

()

RESOLVED FIXED

People

(Reporter: mrbkap, Assigned: mrbkap)

Details

Attachments

(1 file, 1 obsolete file)

We have: PRInt32 pad = clipRect.width >> 2; if (pad <= 0) But the second test relies on sign extension happening for >>, which is not specified in the C standard.
Attached patch Fix (obsolete) — Splinter Review
This preserves the desired behavior.
Attachment #269145 - Flags: superreview?(jst)
Attachment #269145 - Flags: review?(jst)
Attachment #269145 - Flags: superreview?(jst)
Attachment #269145 - Flags: superreview+
Attachment #269145 - Flags: review?(jst)
Attachment #269145 - Flags: review+
But clipRect.width is surely non-negative at that point. So the second test should just be pad==0, no?
I'd rather still make the change to / 4 for clarity. The compiler will happily do the strength reduction for us in this case.
Attachment #269145 - Attachment is obsolete: true
Attachment #269304 - Flags: superreview?(jst)
Attachment #269304 - Flags: review?(mats.palmgren)
Comment on attachment 269304 [details] [diff] [review] With Mats' suggestion Oh, either way is fine with me, I wasn't really objecting to the first patch.
Attachment #269304 - Flags: review?(mats.palmgren) → review+
Attachment #269304 - Flags: superreview?(jst) → superreview+
Fix checked into trunk.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Flags: in-testsuite-
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: