From 17382d7c7e44965972fdbf7f7bdaf28ced09ebcf Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 6 Aug 2022 12:46:05 +0300 Subject: [PATCH] Fix poping uninitialized pointer Closes #113 --- src/interpreter.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/interpreter.cc b/src/interpreter.cc index 03662e6..9388481 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -3033,6 +3033,14 @@ char* programStackPopString(Program* program) void* programStackPopPointer(Program* program) { ProgramValue programValue = programStackPopValue(program); + + // There are certain places in the scripted code where they refer to + // uninitialized exported variables designed to hold objects (pointers). + // If this is one theses places simply return NULL. + if (programValue.opcode == VALUE_TYPE_INT && programValue.integerValue == 0) { + return NULL; + } + if (programValue.opcode != VALUE_TYPE_PTR) { programFatalError("pointer expected, got %x", programValue.opcode); }