The add before division can potentially cause an overflow.
If we divide before adding, no overflow can occur.
Details
Details
- Reviewers
Fabien deadalnix - Group Reviewers
Restricted Project - Commits
- rSTAGING59dff0e81865: Fix potential timedata overflow
rABC59dff0e81865: Fix potential timedata overflow
ninja check
Diff Detail
Diff Detail
- Repository
- rABC Bitcoin ABC
- Branch
- vsorted-overflow
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 10698 Build 19192: Default Diff Build & Tests Build 19191: arc lint + arc unit
Event Timeline
src/timedata.h | ||
---|---|---|
54 ↗ | (On Diff #19879) | Let's say that vSorted[vSortedSize / 2 - 1] == vSorted[vSortedSize / 2 ] == 3. |
src/timedata.h | ||
---|---|---|
54 ↗ | (On Diff #19879) | Although there is a slight change in behavior when both elements are odd (median is 1 less), this result is inconsequential since the time offsets are not super accurate anyway. |
src/timedata.h | ||
---|---|---|
54 ↗ | (On Diff #19879) | int a, b; voila. |