Skip to content

Commit 0ba9781

Browse files
mkustermannCommit Queue
authored andcommitted
[dart2wasm] Use hash of library import uri for private Symbol name mangling
This should make private symbol names more stable and fix a fuzzer report about it. Closes #60967 Change-Id: If57efcf805e6308da6ef94cc8aadb23a68f6252d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436623 Reviewed-by: Ömer Ağacan <[email protected]> Commit-Queue: Martin Kustermann <[email protected]>
1 parent 2e8a93c commit 0ba9781

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/dart2wasm/lib/symbols.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Symbols {
3535
symbolOrdinals.putIfAbsent(symbol, () => symbolOrdinals.length));
3636
}
3737

38-
if (symbol.libraryReference == null) {
38+
final libraryReference = symbol.libraryReference;
39+
if (libraryReference == null) {
3940
return symbol.name;
4041
}
4142

@@ -46,7 +47,7 @@ class Symbols {
4647
// The symbol must be a private identifier (library symbols like `#a.b.c` do
4748
// not have private parts in them).
4849
assert(!symbol.name.contains('.') && symbol.name.startsWith('_'));
49-
return '${symbol.name}@${symbol.libraryReference!.canonicalName.hashCode}';
50+
return '${symbol.name}@${libraryReference.asLibrary.importUri.hashCode}';
5051
}
5152
}
5253

0 commit comments

Comments
 (0)