This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] span: Guard against overflow in span::subspan
ClosedPublic

Authored by miscco on Dec 30 2019, 5:25 AM.

Details

Summary

The calculation _Offset + _Count <= size() may overflow. So use _Count <= size() - _Offset instead.
Note that this is safe due to the previous constraint that _Offset <= size()

Event Timeline

miscco created this revision.Dec 30 2019, 5:25 AM
Herald added a project: Restricted Project. · View Herald Transcript

Gentle Ping

ldionne accepted this revision.Feb 11 2020, 4:39 AM

Thanks for the patch! Could you please kindly rebase on top of master?

This revision is now accepted and ready to land.Feb 11 2020, 4:39 AM
This revision was automatically updated to reflect the committed changes.