Skip to content

Commit 2bfc47b

Browse files
committed
R6: fix valgrind error
Signed-off-by: Bernát Gábor <[email protected]>
1 parent a60763c commit 2bfc47b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

parsers/r-r6class.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,14 @@ static int r6ReadRightSideSymbol (rSubparser *s,
219219
tokenInfo * token1 = NULL;
220220
if (strcmp (tokenString (token), "R6") == 0)
221221
{
222-
tokenInfo * token0 = rNewToken ();
222+
token0 = rNewToken ();
223223
tokenRead (token0);
224224
if (!tokenIsType (token0, R_SCOPE))
225225
goto reject;
226226
if (strcmp (tokenString (token0), "::"))
227227
goto reject;
228228

229-
tokenInfo * token1 = rNewToken ();
229+
token1 = rNewToken ();
230230
tokenRead (token1);
231231
if (!tokenIsType (token1, R_SYMBOL))
232232
goto reject;
@@ -252,11 +252,12 @@ static int r6ReadRightSideSymbol (rSubparser *s,
252252
}
253253
return CORK_NIL;
254254
reject:
255-
if (token1)
255+
/* For incomplete "R6::" cases, we don't want to unread the "::" token
256+
as the main R parser may not handle it well. */
257+
if (token1 && tokenIsType(token1, R_SYMBOL)) {
256258
tokenUnread (token1);
257-
if (token0)
258-
tokenUnread (token0);
259-
/* tokenDelete accepts NULL. */
259+
}
260+
/* Don't unread token0 (::) to prevent main parser confusion */
260261
tokenDelete (token1);
261262
tokenDelete (token0);
262263

0 commit comments

Comments
 (0)