| Index: runtime/platform/utils.h
|
| ===================================================================
|
| --- runtime/platform/utils.h (revision 3811)
|
| +++ runtime/platform/utils.h (working copy)
|
| @@ -154,6 +154,18 @@
|
| if (i < 10) return static_cast<char>('0' + i);
|
| return static_cast<char>('A' + (i - 10));
|
| }
|
| +
|
| + // Perform a range check, checking if
|
| + // offset + count <= length
|
| + // without the risk of integer overflow.
|
| + static inline bool RangeCheck(intptr_t offset,
|
| + intptr_t count,
|
| + intptr_t length) {
|
| + return offset >= 0 &&
|
| + count >= 0 &&
|
| + length >= 0 &&
|
| + count <= (length - offset);
|
| + }
|
| };
|
|
|
| } // namespace dart
|
|
|