Skip to content

Commit 377117f

Browse files
authored
fix: check for null chunk ptr (#127)
1 parent c821f88 commit 377117f

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

echion/stack_chunk.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ void StackChunk::update(_PyStackChunk* chunk_addr)
5656

5757
origin = chunk_addr;
5858
// if data_size is not enough, reallocate
59-
if (chunk.size > data_capacity)
59+
if (chunk.size > data_capacity || data.get() == nullptr)
6060
{
6161
data_capacity = chunk.size;
6262
char* new_data = (char*)realloc(data.get(), data_capacity);
@@ -92,6 +92,11 @@ void* StackChunk::resolve(void* address)
9292
{
9393
_PyStackChunk* chunk = (_PyStackChunk*)data.get();
9494

95+
if (chunk == nullptr)
96+
{
97+
return address;
98+
}
99+
95100
// Check if this chunk contains the address
96101
if (address >= origin && address < (char*)origin + chunk->size)
97102
return (char*)chunk + ((char*)address - (char*)origin);

0 commit comments

Comments
 (0)