Closed Bug 561848 Opened 14 years ago Closed 14 years ago

nsNavHistoryContainerResultNode::GetChildIndex is assigning a signed int to an unsigned one

Categories

(Toolkit :: Places, defect)

defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.9.3a5

People

(Reporter: mak, Assigned: mak)

References

Details

(Keywords: regression)

Attachments

(2 files)

*_retval = FindChild(static_cast<nsNavHistoryResultNode*>(aNode));
  if (*_retval == -1)

FindChild returns a signed int that can be -1, but *_retval is unsigned, this could explain some of the random failures i've seen.
Blocks: 520659
Keywords: regression
Attached patch patch v1.0Splinter Review
Attachment #441611 - Flags: review?(dietrich)
Attachment #441611 - Flags: review?(dietrich) → review+
is there a way for us to test a failure scenario here?
oh, it should be possible to invoke the method, pass it a not existing node and get back an index instead, so yeah i think i can make a test (actually i wanted to do it yesterday but i was surprised by the thunderstorm, and just attached the patch)
Flags: in-testsuite?
pushed the fix:
http://hg.mozilla.org/mozilla-central/rev/06b78c632960

i'm working on the test, will follow shortly.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a5
So, unfortunatly i cannot test the wrong assignment because cpp does not have strict type safety, in this case it is clearly wrong, but on our tier platforms that is probably going to be unnoticed, Windows does not even warn about the signed assign to an unsigned int (Linux GCC does luckily). And actually the condition was still satisfied thanks to an implicit conversion. To test this i should add more than 2^32 nodes, that's not feasible.
Thus, this is just a functionality test for the API, but passes regardless status of this bug.
Attachment #441803 - Flags: review?(dietrich)
Comment on attachment 441803 [details] [diff] [review]
functionality test

code coverage ftw, i guess.
Attachment #441803 - Flags: review?(dietrich) → review+
http://hg.mozilla.org/mozilla-central/rev/d36b48ffd03d
Flags: in-testsuite? → in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: