Prevented a potential null access
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import engine;
|
import engine;
|
||||||
|
|
||||||
|
//this function must always be called, or the engine won't run
|
||||||
initWindow("Airport Game", 800, 600, false);
|
initWindow("Airport Game", 800, 600, false);
|
||||||
|
|
||||||
loadRootNode("assets/scripts/root.toy");
|
loadRootNode("assets/scripts/root.toy");
|
||||||
|
|||||||
@@ -146,7 +146,9 @@ void freeEngine() {
|
|||||||
|
|
||||||
static void execStep() {
|
static void execStep() {
|
||||||
//call onStep
|
//call onStep
|
||||||
callEngineNode(engine.rootNode, &engine.interpreter, "onStep");
|
if (engine.rootNode != NULL) {
|
||||||
|
callEngineNode(engine.rootNode, &engine.interpreter, "onStep");
|
||||||
|
}
|
||||||
|
|
||||||
//poll events
|
//poll events
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|||||||
@@ -191,7 +191,9 @@ static int nativeLoadRootNode(Interpreter* interpreter, LiteralArray* arguments)
|
|||||||
size_t originalSize = engine.interpreter.length;
|
size_t originalSize = engine.interpreter.length;
|
||||||
int originalCount = engine.interpreter.count;
|
int originalCount = engine.interpreter.count;
|
||||||
int originalCodeStart = engine.interpreter.codeStart;
|
int originalCodeStart = engine.interpreter.codeStart;
|
||||||
|
|
||||||
initEngineNode(engine.rootNode, &engine.interpreter, tb, size);
|
initEngineNode(engine.rootNode, &engine.interpreter, tb, size);
|
||||||
|
|
||||||
engine.interpreter.bytecode = originalTb;
|
engine.interpreter.bytecode = originalTb;
|
||||||
engine.interpreter.length = originalSize;
|
engine.interpreter.length = originalSize;
|
||||||
engine.interpreter.count = originalCount;
|
engine.interpreter.count = originalCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user