This is an archive of the discontinued Mercurial Phabricator instance.

bdiff: Handle the possibility of an integer overflow when allocating
ClosedPublic

Authored by alex_gaynor on Jan 17 2018, 4:37 PM.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

alex_gaynor created this revision.Jan 17 2018, 4:37 PM
durin42 accepted this revision.Jan 17 2018, 4:40 PM
durin42 added a subscriber: durin42.

Thanks!

This revision is now accepted and ready to land.Jan 17 2018, 4:40 PM
indygreg added inline comments.
mercurial/bdiff.c
44

Memory throughput is already a bottleneck in bdiff code. Is there an impact on hg perfbdiff with the change from malloc() to calloc()?

Before:

! wall 0.002096 comb 0.000000 user 0.000000 sys 0.000000 (best of 1329)

After:

! wall 0.002094 comb 0.000000 user 0.000000 sys 0.000000 (best of 1355)

so, uh, calloc is slightly faster? but not enough to even matter.

Wait, I'm a moron, I forgot to do ./hg instead of hg. New results:

Before:

! wall 0.002058 comb 0.000000 user 0.000000 sys 0.000000 (best of 1293)

After:

! wall 0.002107 comb 0.000000 user 0.000000 sys 0.000000 (best of 1342)

so calloc() is very slightly slower, but it's so little I'm not inclined to sweat it.

This revision was automatically updated to reflect the committed changes.