[all-commits] [llvm/llvm-project] b5abd5: [libc++] span: Guard against overflow in span::sub...

Louis Dionne via All-commits all-commits at lists.llvm.org
Wed Feb 12 07:21:55 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b5abd50f06966af28df4f80850f006c9cda7a07e
      https://github.com/llvm/llvm-project/commit/b5abd50f06966af28df4f80850f006c9cda7a07e
  Author: Louis Dionne <ldionne at apple.com>
  Date:   2020-02-12 (Wed, 12 Feb 2020)

  Changed paths:
    M libcxx/include/span
    A libcxx/test/std/containers/views/span.sub/subspan.fail.cpp

  Log Message:
  -----------
  [libc++] span: Guard against overflow in span::subspan

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().

Patch by Michael Schellenberger Costa.

Differential Revision: https://reviews.llvm.org/D71998




More information about the All-commits mailing list