Skip to content

Commit 60650fa

Browse files
authored
Merge pull request #3262 from masatake/kotlin-fix-membug
Kotlin: don't delete vString before making the tag for the string
2 parents 1fad842 + 2b952e2 commit 60650fa

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
main input.kt /^fun `main`(args:Array<String>) {$/;" m
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fun `main`(args:Array<String>) {
2+
println("hello, world!")
3+
}

peg/kotlin_post.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static void makeKotlinTag (struct parserCtx *auxil, const char *name, long offse
3131
int k = PEEK_KIND(auxil);
3232
if (k == K_IGNORE) return;
3333
tagEntryInfo e;
34+
char *stripped = NULL;
3435
if (*name != '`')
3536
{
3637
initTagEntry(&e, name, k);
@@ -39,9 +40,8 @@ static void makeKotlinTag (struct parserCtx *auxil, const char *name, long offse
3940
size_t len = strlen(name);
4041
Assert(len >= 2);
4142
len -= 2;
42-
vString *stripped = vStringNewNInit(name + 1, len);
43-
initTagEntry(&e, vStringValue(stripped), k);
44-
vStringDelete(stripped);
43+
stripped = eStrndup (name + 1, len);
44+
initTagEntry(&e, stripped, k);
4545
}
4646
e.lineNumber = getInputLineNumberForFileOffset (offset);
4747
e.filePosition = getInputFilePositionForLine (e.lineNumber);
@@ -51,6 +51,8 @@ static void makeKotlinTag (struct parserCtx *auxil, const char *name, long offse
5151
{
5252
SET_SCOPE(auxil, scope_index);
5353
}
54+
if (stripped)
55+
eFree (stripped);
5456
}
5557

5658
#ifdef DEBUG

0 commit comments

Comments
 (0)