reject sizes that will overflow in SkSpan
Change-Id: Ie1eac40fe678529410f3ae4ab0cc7460dedfa4c2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/408296 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
6529990763
commit
82fdab48ab
@ -26,7 +26,9 @@ template <typename T>
|
||||
class SkSpan {
|
||||
public:
|
||||
constexpr SkSpan() : fPtr{nullptr}, fSize{0} {}
|
||||
constexpr SkSpan(T* ptr, size_t size) : fPtr{ptr}, fSize{size} {}
|
||||
constexpr SkSpan(T* ptr, size_t size) : fPtr{ptr}, fSize{size} {
|
||||
SkASSERT(size < kMaxSize);
|
||||
}
|
||||
template <typename U, typename = typename std::enable_if<std::is_same<const U, T>::value>::type>
|
||||
constexpr SkSpan(const SkSpan<U>& that) : fPtr(that.data()), fSize{that.size()} {}
|
||||
constexpr SkSpan(const SkSpan& o) = default;
|
||||
@ -65,6 +67,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr size_t kMaxSize = std::numeric_limits<size_t>::max() / sizeof(T);
|
||||
T* fPtr;
|
||||
size_t fSize;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user