[PATCH 0/1] MR10590: vbscript: Reject 'Set Me' with error 1037 instead of crashing.
Add a check in the Set statement grammar rule to report error 1037 "Invalid use of 'Me' keyword" for 'Set Me = ...', matching Windows. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10590
From: Francis De Brabandere <francisdb@gmail.com> Add a check in the Set statement grammar rule to report error 1037 "Invalid use of 'Me' keyword" for 'Set Me = ...', matching Windows. --- dlls/vbscript/parser.y | 3 ++- dlls/vbscript/tests/run.c | 10 ++++++++++ dlls/vbscript/vbscript.rc | 1 + dlls/vbscript/vbscript_defs.h | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/vbscript/parser.y b/dlls/vbscript/parser.y index a7d95eaa707..007ea602349 100644 --- a/dlls/vbscript/parser.y +++ b/dlls/vbscript/parser.y @@ -238,7 +238,8 @@ SimpleStatement | tEXIT tFUNCTION { $$ = new_statement(ctx, STAT_EXITFUNC, 0, @2); CHECK_ERROR; } | tEXIT tPROPERTY { $$ = new_statement(ctx, STAT_EXITPROP, 0, @2); CHECK_ERROR; } | tEXIT tSUB { $$ = new_statement(ctx, STAT_EXITSUB, 0, @2); CHECK_ERROR; } - | tSET CallExpression '=' Expression { $$ = new_set_statement(ctx, @$, $2, $4); CHECK_ERROR; } + | tSET CallExpression '=' Expression { if($2->type == EXPR_ME) { ctx->error_loc = @3; ctx->hres = MAKE_VBSERROR(VBSE_INVALID_USE_OF_ME); YYABORT; } + $$ = new_set_statement(ctx, @$, $2, $4); CHECK_ERROR; } | tSTOP { $$ = new_statement(ctx, STAT_STOP, 0, @$); CHECK_ERROR; } | tON tERROR tRESUME tNEXT { $$ = new_onerror_statement(ctx, @$, TRUE); CHECK_ERROR; } | tON tERROR tGOTO '0' { $$ = new_onerror_statement(ctx, @$, FALSE); CHECK_ERROR; } diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 70ccd517254..b90dffc7faa 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -3079,6 +3079,16 @@ static void test_parse_errors(void) L"\x00e9var = 1\n", 0, 0, NULL, S_OK, 1032 + }, + { + /* Invalid use of 'Me' - Set Me inside class - error 1037 */ + L"Class C\n" + " Sub T()\n" + " Set Me = Nothing\n" + " End Sub\n" + "End Class\n", + 2, 11, + NULL, S_OK, 1037 } }; HRESULT hres; diff --git a/dlls/vbscript/vbscript.rc b/dlls/vbscript/vbscript.rc index 5e3adddc789..81d3cecb1d7 100644 --- a/dlls/vbscript/vbscript.rc +++ b/dlls/vbscript/vbscript.rc @@ -80,6 +80,7 @@ STRINGTABLE VBSE_INVALID_NUMBER "Invalid number" VBSE_INVALID_CHAR "Invalid character" VBSE_UNTERMINATED_STRING "Unterminated string constant" + VBSE_INVALID_USE_OF_ME "Invalid use of 'Me' keyword" VBSE_LOOP_WITHOUT_DO "'loop' without 'do'" VBSE_INVALID_EXIT "Invalid 'exit' statement" VBSE_NAME_REDEFINED "Name redefined" diff --git a/dlls/vbscript/vbscript_defs.h b/dlls/vbscript/vbscript_defs.h index 0dc7b677517..132f2fa7b4c 100644 --- a/dlls/vbscript/vbscript_defs.h +++ b/dlls/vbscript/vbscript_defs.h @@ -291,6 +291,7 @@ #define VBSE_INVALID_NUMBER 1031 #define VBSE_INVALID_CHAR 1032 #define VBSE_UNTERMINATED_STRING 1033 +#define VBSE_INVALID_USE_OF_ME 1037 #define VBSE_LOOP_WITHOUT_DO 1038 #define VBSE_INVALID_EXIT 1039 #define VBSE_NAME_REDEFINED 1041 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10590
participants (2)
-
Francis De Brabandere -
Francis De Brabandere (@francisdb)