Remove always-true clause from NS_ASSERTION in nsNavBookmarks::AdjustIndices (Coverity CID 1274453)
Categories
(Toolkit :: Places, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox154 | --- | fixed |
People
(Reporter: Sylvestre, Assigned: tmcnulty387)
References
(Blocks 1 open bug)
Details
(Keywords: good-first-bug, Whiteboard: [lang=c++])
Attachments
(1 file)
Filing as a good first bug to learn workflows.
In toolkit/components/places/nsNavBookmarks.cpp, nsNavBookmarks::AdjustIndices contains an assertion clause that Coverity flagged as a dead/tautological guard (CID 1274453).
The assertion is:
NS_ASSERTION(
aStartIndex >= 0 && aEndIndex <= INT32_MAX && aStartIndex <= aEndIndex,
"Bad indices");
The aEndIndex <= INT32_MAX clause is always true: aEndIndex is an int32_t, whose maximum possible value is exactly INT32_MAX, so the comparison can never be false.
The fix is to drop that clause, leaving the two meaningful invariants:
NS_ASSERTION(aStartIndex >= 0 && aStartIndex <= aEndIndex, "Bad indices");
This is behavior-preserving: the removed clause never contributed to the assertion result.
Link to the code:
https://searchfox.org/mozilla-central/source/toolkit/components/places/nsNavBookmarks.cpp
To verify the fix, the tree should still build:
./mach build binaries
Tutorial to contribute:
https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
https://firefox-source-docs.mozilla.org/contributing/stack_quickref.html
Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.
| Assignee | ||
Comment 1•2 months ago
|
||
Updated•2 months ago
|
Comment 3•2 months ago
|
||
| bugherder | ||
Updated•1 month ago
|
Description
•