Skip to content

Commit 04bec9a

Browse files
committed
Fix valgrind error
Signed-off-by: Bernát Gábor <[email protected]>
1 parent e7d47bf commit 04bec9a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TestCase1 input.r /^TestCase1 <- R6::SomethingElse("TestCase1")$/;" globalVar language:R end:6
2+
TestCase2 input.r /^TestCase2 <- R6::$/;" globalVar language:R end:10
3+
TestCase3 input.r /^TestCase3 <- R6::R6Clas("TestCase3")$/;" globalVar language:R end:12

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)