Skip to content

Commit 4ff4a5c

Browse files
authored
Fix potential null pointer dereference in FlutterDartProject (flutter#6035)
If `FlutterDartProject` found an `FLTLibraryPath` entry in an iOS application's `Info.plist`, it assumed that values that were valid filesystem paths were paths to bundles. If the attempt to retrieve the `NSBundle` fails, `FlutterDartProject` ignored the failure and then would assign `nil` to a C++ `std::string`, resulting in a null pointer dereference. Add some failure checks to prevent this.
1 parent 9e26174 commit 4ff4a5c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@
7373
NSString* libraryName = [mainBundle objectForInfoDictionaryKey:@"FLTLibraryPath"];
7474
NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:@""];
7575
if (libraryPath.length > 0) {
76-
settings.application_library_path =
77-
[NSBundle bundleWithPath:libraryPath].executablePath.UTF8String;
76+
NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath;
77+
if (executablePath.length > 0) {
78+
settings.application_library_path = executablePath.UTF8String;
79+
}
7880
}
7981
}
8082

@@ -84,8 +86,11 @@
8486
NSString* applicationFrameworkPath =
8587
[mainBundle pathForResource:@"Frameworks/App.framework" ofType:@""];
8688
if (applicationFrameworkPath.length > 0) {
87-
settings.application_library_path =
88-
[NSBundle bundleWithPath:applicationFrameworkPath].executablePath.UTF8String;
89+
NSString* executablePath =
90+
[NSBundle bundleWithPath:applicationFrameworkPath].executablePath;
91+
if (executablePath.length > 0) {
92+
settings.application_library_path = executablePath.UTF8String;
93+
}
8994
}
9095
}
9196
}

0 commit comments

Comments
 (0)