ref: 09c9395ff8b23b5c7beb431d0228d5e2129d56d6
parent: 81047afb4bf5e73b7f9a388268124241e06b24bd
author: ISSOtm <[email protected]>
date: Sun Oct 13 11:17:34 EDT 2019
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.
--- a/src/link/patch.c
+++ b/src/link/patch.c
@@ -192,11 +192,13 @@
/* 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 @@
/* 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, "@")) {