Skip to content

Commit 45862f9

Browse files
authored
Prevent access outside buffer (GH-26012)
1 parent 8e8307d commit 45862f9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Python/ceval.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4794,8 +4794,10 @@ scan_back_to_entry_start(unsigned char *p) {
47944794
}
47954795

47964796
static inline unsigned char *
4797-
skip_to_next_entry(unsigned char *p) {
4798-
for (; (p[0]&128) == 0; p++);
4797+
skip_to_next_entry(unsigned char *p, unsigned char *end) {
4798+
while (p < end && ((p[0] & 128) == 0)) {
4799+
p++;
4800+
}
47994801
return p;
48004802
}
48014803

@@ -4863,7 +4865,7 @@ get_exception_handler(PyCodeObject *code, int index)
48634865
parse_block(scan, &res);
48644866
return res;
48654867
}
4866-
scan = skip_to_next_entry(scan);
4868+
scan = skip_to_next_entry(scan, end);
48674869
}
48684870
res.b_handler = -1;
48694871
return res;

0 commit comments

Comments
 (0)