Fix NULL deref when fetching an unknown symbol in RPN expressions

was being overwritten with the result, so
was meaningless. Using a temporary instead is better.
This commit is contained in:
ISSOtm
2019-10-13 15:17:34 +02:00
parent 81047afb4b
commit 09c9395ff8

View File

@@ -192,11 +192,13 @@ static int32_t computeRPNExpr(struct Patch const *patch,
/* If the symbol is defined elsewhere... */
if (symbol->type == SYMTYPE_IMPORT) {
symbol = sym_GetSymbol(symbol->name);
if (!symbol)
struct Symbol const *symbolDefinition =
sym_GetSymbol(symbol->name);
if (!symbolDefinition)
errx(1, "%s(%d): Unknown symbol \"%s\"",
patch->fileName, patch->lineNo,
symbol->name);
symbol = symbolDefinition;
}
value = symbol->section->bank;
@@ -250,11 +252,13 @@ static int32_t computeRPNExpr(struct Patch const *patch,
/* If the symbol is defined elsewhere... */
if (symbol->type == SYMTYPE_IMPORT) {
symbol = sym_GetSymbol(symbol->name);
if (!symbol)
struct Symbol const *symbolDefinition =
sym_GetSymbol(symbol->name);
if (!symbolDefinition)
errx(1, "%s(%d): Unknown symbol \"%s\"",
patch->fileName, patch->lineNo,
symbol->name);
symbol = symbolDefinition;
}
if (!strcmp(symbol->name, "@")) {