From 5c17ff0595259dd14f4a53c3761c5fca34c45f79 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 28 Feb 2021 14:46:13 -0500 Subject: [PATCH] Libeval: don't try to dereference invalid STRUCT_REF parent Fixes https://gitlab.com/kicad/code/kicad/-/issues/7764 --- common/libeval_compiler/libeval_compiler.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index 1debd2091c..4f812f114c 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -841,8 +841,19 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext ) if( node->leaf[0]->op != TR_IDENTIFIER ) { - reportError( CST_CODEGEN, _( "Unknown parent of property" ), - node->leaf[0]->srcPos - (int) node->leaf[0]->value.str->length() ); + int pos = node->leaf[0]->srcPos; + + if( node->leaf[0]->value.str ) + pos -= static_cast( node->leaf[0]->value.str->length() ); + + reportError( CST_CODEGEN, _( "Unknown parent of property" ), pos ); + + node->leaf[0]->isVisited = true; + node->leaf[1]->isVisited = true; + + node->SetUop( TR_UOP_PUSH_VALUE, 0.0 ); + node->isTerminal = true; + break; } switch( node->leaf[1]->op )