Skip to content

Commit 5687acc

Browse files
Add bounds checking to ExtractSubrange.
PiperOrigin-RevId: 856826403
1 parent d2a42e7 commit 5687acc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/google/protobuf/repeated_ptr_field.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,9 +1805,9 @@ template <typename Element>
18051805
inline void RepeatedPtrField<Element>::ExtractSubrangeWithArena(
18061806
Arena* arena, int start, int num, Element** elements) {
18071807
ABSL_DCHECK_EQ(arena, GetArena());
1808-
ABSL_DCHECK_GE(start, 0);
1809-
ABSL_DCHECK_GE(num, 0);
1810-
ABSL_DCHECK_LE(start + num, size());
1808+
internal::RuntimeAssertInBoundsGE(start, 0);
1809+
internal::RuntimeAssertInBoundsGE(num, 0);
1810+
internal::RuntimeAssertInBoundsLE(static_cast<int64_t>(start) + num, size());
18111811

18121812
if (num == 0) return;
18131813

0 commit comments

Comments
 (0)