From b5d4a7dd355b8fdc76756e6ec3cb55b165da59b3 Mon Sep 17 00:00:00 2001 From: Josh Davies Date: Tue, 31 Mar 2026 11:53:41 +0100 Subject: [PATCH] fix: forbid non-dollar names starting with $ --- check/fixes.frm | 15 +++++++++++++++ sources/comexpr.c | 7 +++---- sources/names.c | 1 + 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/check/fixes.frm b/check/fixes.frm index f2793f7c..801d09e3 100644 --- a/check/fixes.frm +++ b/check/fixes.frm @@ -4490,6 +4490,21 @@ assert warning?("Excess information in symmetric properties") assert warning?("Illegal information in number of arguments properties") assert warning?("Undefined $-variable") *--#] Issue766 : +*--#[ Issue782 : +S $s; +V $v; +I $i; +F $f; +Set $ss; +Local $test = 1; +.end +assert compile_error?("Illegally formed name in symbol statement") +assert compile_error?("Illegally formed name in vector statement") +assert compile_error?("Illegally formed name in index statement") +assert compile_error?("Illegally formed function/tensor name") +assert compile_error?("Illegal name for set") +assert compile_error?("Illegal name for expression") +*--#] Issue782 : *--#[ Issue796 : * Regression: the fix for 796 deadlocks here: Symbol x; diff --git a/sources/comexpr.c b/sources/comexpr.c index f352b447..2d608f8b 100644 --- a/sources/comexpr.c +++ b/sources/comexpr.c @@ -112,12 +112,11 @@ int DoExpr(UBYTE *inp, int type, int par) else p++; } if ( *p ) { /* Variety with the = sign */ - if ( ( q = SkipAName(inp) ) == 0 || q[-1] == '_' ) { + q = SkipAName(inp); + if ( *inp == '$' || q == 0 || q[-1] == '_' ) { MesPrint("&Illegal name for expression"); error = 1; - if ( q[-1] == '_' ) { - while ( FG.cTable[*q] < 2 || *q == '_' ) q++; - } + return(error); } else { c = *q; *q = 0; diff --git a/sources/names.c b/sources/names.c index c2cf3c7b..3d52dbf2 100644 --- a/sources/names.c +++ b/sources/names.c @@ -3261,6 +3261,7 @@ int TestName(UBYTE *name) } while ( *name ) { if ( *name == '_' ) return(-1); + if ( *name == '$' ) return(-1); name++; } return(0);