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
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
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. |