@@ -1568,15 +1568,29 @@ cache_tlbc_array(RemoteUnwinderObject *unwinder, uintptr_t code_addr, uintptr_t
15681568 TLBCCacheEntry * entry = NULL ;
15691569
15701570 // Read the TLBC array pointer
1571- if (read_ptr (unwinder , tlbc_array_addr , & tlbc_array_ptr ) != 0 || tlbc_array_ptr == 0 ) {
1571+ if (read_ptr (unwinder , tlbc_array_addr , & tlbc_array_ptr ) != 0 ) {
1572+ PyErr_SetString (PyExc_RuntimeError , "Failed to read TLBC array pointer" );
15721573 set_exception_cause (unwinder , PyExc_RuntimeError , "Failed to read TLBC array pointer" );
1574+ return 0 ; // Read error
1575+ }
1576+
1577+ // Validate TLBC array pointer
1578+ if (tlbc_array_ptr == 0 ) {
1579+ PyErr_SetString (PyExc_RuntimeError , "TLBC array pointer is NULL" );
15731580 return 0 ; // No TLBC array
15741581 }
15751582
15761583 // Read the TLBC array size
15771584 Py_ssize_t tlbc_size ;
1578- if (_Py_RemoteDebug_PagedReadRemoteMemory (& unwinder -> handle , tlbc_array_ptr , sizeof (tlbc_size ), & tlbc_size ) != 0 || tlbc_size <= 0 ) {
1585+ if (_Py_RemoteDebug_PagedReadRemoteMemory (& unwinder -> handle , tlbc_array_ptr , sizeof (tlbc_size ), & tlbc_size ) != 0 ) {
1586+ PyErr_SetString (PyExc_RuntimeError , "Failed to read TLBC array size" );
15791587 set_exception_cause (unwinder , PyExc_RuntimeError , "Failed to read TLBC array size" );
1588+ return 0 ; // Read error
1589+ }
1590+
1591+ // Validate TLBC array size
1592+ if (tlbc_size <= 0 ) {
1593+ PyErr_SetString (PyExc_RuntimeError , "Invalid TLBC array size" );
15801594 return 0 ; // Invalid size
15811595 }
15821596
0 commit comments