Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 3a4bf7f

Browse files
authored
Merge pull request #2117 from timotheecour/pr_fix_18531_demangle
Fix 18531 - core.exception.RangeError@src/core/demangle.d(216): Range violation
2 parents ce8c251 + a8415b6 commit 3a4bf7f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/core/demangle.d

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ pure @safe:
208208
{
209209
assert( contains( dst[0 .. len], val ) );
210210
debug(info) printf( "removing (%.*s)\n", cast(int) val.length, val.ptr );
211-
212211
size_t v = &val[0] - &dst[0];
212+
assert( len >= val.length && len <= dst.length );
213+
len -= val.length;
213214
for (size_t p = v; p < len; p++)
214215
dst[p] = dst[p + val.length];
215-
len -= val.length;
216216
}
217217
}
218218

@@ -2562,6 +2562,15 @@ version(unittest)
25622562
static assert( r == table[i][1],
25632563
"demangled \"" ~ table[i][0] ~ "\" as \"" ~ r ~ "\" but expected \"" ~ table[i][1] ~ "\"");
25642564
}
2565+
2566+
{
2567+
// https://issues.dlang.org/show_bug.cgi?id=18531
2568+
auto symbol = `_D3std3uni__T6toCaseS_DQvQt12toLowerIndexFNaNbNiNewZtVii1043S_DQCjQCi10toLowerTabFNaNbNiNemZwSQDo5ascii7toLowerTAyaZQDzFNaNeQmZ14__foreachbody2MFNaNeKmKwZ14__foreachbody3MFNaNeKwZi`;
2569+
auto demangled = `pure @trusted int std.uni.toCase!(std.uni.toLowerIndex(dchar), 1043, std.uni.toLowerTab(ulong), std.ascii.toLower, immutable(char)[]).toCase(immutable(char)[]).__foreachbody2(ref ulong, ref dchar).__foreachbody3(ref dchar)`;
2570+
auto dst = new char[200];
2571+
auto ret = demangle( symbol, dst);
2572+
assert( ret == demangled );
2573+
}
25652574
}
25662575

25672576
unittest

0 commit comments

Comments
 (0)