Skip to content

Commit 3d92a75

Browse files
mdempskycommit-bot@chromium.org
authored andcommitted
[vm] Censor mirroring of dart:ffi when --enable-ffi=false
Updates #37044. Change-Id: I51b11fe8f326e1f98d86fc674147176afae873a9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105327 Commit-Queue: Matthew Dempsky <[email protected]> Commit-Queue: Ryan Macnak <[email protected]> Reviewed-by: Samir Jindel <[email protected]> Reviewed-by: Ryan Macnak <[email protected]>
1 parent 41eea71 commit 3d92a75

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

runtime/lib/mirrors.cc

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,23 @@ static RawInstance* CreateClassMirror(const Class& cls,
331331
return CreateMirror(Symbols::_LocalClassMirror(), args);
332332
}
333333

334+
static bool IsCensoredLibrary(const String& url) {
335+
static const char* const censored_libraries[] = {
336+
"dart:_builtin",
337+
"dart:_vmservice",
338+
"dart:vmservice_io",
339+
};
340+
for (const char* censored_library : censored_libraries) {
341+
if (url.Equals(censored_library)) {
342+
return true;
343+
}
344+
}
345+
if (!Api::IsFfiEnabled() && url.Equals(Symbols::DartFfi())) {
346+
return true;
347+
}
348+
return false;
349+
}
350+
334351
static RawInstance* CreateLibraryMirror(Thread* thread, const Library& lib) {
335352
Zone* zone = thread->zone();
336353
ASSERT(!lib.IsNull());
@@ -340,17 +357,9 @@ static RawInstance* CreateLibraryMirror(Thread* thread, const Library& lib) {
340357
str = lib.name();
341358
args.SetAt(1, str);
342359
str = lib.url();
343-
const char* censored_libraries[] = {
344-
"dart:_builtin",
345-
"dart:_vmservice",
346-
"dart:vmservice_io",
347-
NULL,
348-
};
349-
for (intptr_t i = 0; censored_libraries[i] != NULL; i++) {
350-
if (str.Equals(censored_libraries[i])) {
351-
// Censored library (grumble).
352-
return Instance::null();
353-
}
360+
if (IsCensoredLibrary(str)) {
361+
// Censored library (grumble).
362+
return Instance::null();
354363
}
355364
args.SetAt(2, str);
356365
return CreateMirror(Symbols::_LocalLibraryMirror(), args);

0 commit comments

Comments
 (0)