Opened 2 years ago

Closed 21 months ago

#13784 closed defect (fixed)

GRIM: Run-Time Check Failure #3

Reported by: henke37 Owned by: dwatteau
Priority: normal Component: Engine: Grim
Version: Keywords:
Cc: Game: Escape from Monkey Island

Description

In debug builds with MSVC, each time (and frame!) I press a key I get a runtime error.

Run-Time Check Failure #3 - The variable 'yyval' is being used without being initialized.

This happens on line 1417 of lstx.cpp

Naturally, this makes playing the game an exercise in frustration.

Change History (2)

comment:1 by dwatteau, 21 months ago

Does the following change make a difference?

diff --git a/engines/grim/lua/lstx.cpp b/engines/grim/lua/lstx.cpp
index ab99141a971..c3fae583d6a 100644
--- a/engines/grim/lua/lstx.cpp
+++ b/engines/grim/lua/lstx.cpp
@@ -1068,8 +1068,16 @@ yydefault:
 	/* Do a reduction.  yyn is the number of a rule to reduce with.  */
 yyreduce:
 	yylen = yyr2[yyn];
-	if (yylen > 0)
-		yyval = yyvsp[1 - yylen]; /* implement default value of the action */
+
+	/* If YYLEN is nonzero, implement the default value of the action:
+	   `$$ = $1'.
+
+	   Otherwise, the following line sets YYVAL to the semantic value of
+	   the lookahead token.  This behavior is undocumented and Bison
+	   users should not rely upon it.  Assigning to YYVAL
+	   unconditionally makes the parser a bit smaller, and it avoids a
+	   GCC warning that YYVAL may be used uninitialized.  */
+	yyval = yyvsp[1-yylen];
 
 	switch (yyn) {
 

From Bison 1.28c, 2000-10-02: https://git.savannah.gnu.org/cgit/bison.git/commit/?id=da9abf4366d824a23da3d2416856e9a482794eb1 (since our lstx.cpp was made with the ancient GNU Bison 1.25).

comment:2 by bluegr, 21 months ago

Owner: set to dwatteau
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.