Skip to content

Commit 7e01e05

Browse files
ambvpablogsal
andauthored
Add MAX_ITERATIONS
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
1 parent 713ac39 commit 7e01e05

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Modules/_testexternalinspection.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,13 @@ append_awaited_by_for_thread(
14901490
return -1;
14911491
}
14921492

1493-
while ((uintptr_t)task_node.next != head_addr) {
1493+
size_t iteration_count = 0;
1494+
const size_t MAX_ITERATIONS = 100000; // Reasonable upper bound
1495+
while ((uintptr_t)task_node.next != head_addr) {
1496+
if (++iteration_count > MAX_ITERATIONS) {
1497+
PyErr_SetString(PyExc_RuntimeError, "Task list appears corrupted");
1498+
return -1;
1499+
}
14941500
uintptr_t task_addr = (uintptr_t)task_node.next
14951501
- async_offsets->asyncio_task_object.task_node;
14961502

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy