From d02c8e4f874563ad62fe0dd0fc2cf141fb4d1d36 Mon Sep 17 00:00:00 2001 From: Adrian Niculescu <15037449+adrian-niculescu@users.noreply.github.com> Date: Fri, 28 Aug 2026 13:10:55 +0300 Subject: [PATCH 1/2] feat(runtime): add nullability annotations to NativeScript.h Without them every pointer in the embedder API imports into Swift as implicitly unwrapped, which hides the contract the implementation already has: BaseDir, the script string and the Config argument are required (their UTF8String feeds a std::string), while ApplicationPath, MetadataPtr and Arguments are optional with defaults (BaseDir/app, the __TNSMetadata section, no inspector arguments). initWithConfig: never returns nil. --- NativeScript/NativeScript.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/NativeScript/NativeScript.h b/NativeScript/NativeScript.h index f9bcc9f1..85b56f9e 100644 --- a/NativeScript/NativeScript.h +++ b/NativeScript/NativeScript.h @@ -1,14 +1,16 @@ #import +NS_ASSUME_NONNULL_BEGIN + @interface Config : NSObject @property (nonatomic, retain) NSString* BaseDir; -@property (nonatomic, retain) NSString* ApplicationPath; -@property (nonatomic) void* MetadataPtr; +@property (nonatomic, retain, nullable) NSString* ApplicationPath; +@property (nonatomic, nullable) void* MetadataPtr; @property BOOL IsDebug; @property BOOL LogToSystemConsole; @property int ArgumentsCount; -@property (nonatomic) char** Arguments; +@property (nonatomic) char* _Nullable* _Nullable Arguments; @end @@ -26,3 +28,5 @@ - (bool)liveSync; @end + +NS_ASSUME_NONNULL_END From ae42f486e1c19e79f459189c5cf7e9496e717f55 Mon Sep 17 00:00:00 2001 From: Adrian Niculescu <15037449+adrian-niculescu@users.noreply.github.com> Date: Fri, 28 Aug 2026 13:27:16 +0300 Subject: [PATCH 2/2] fix(runtime): read no inspector flags from a nil Arguments array Config.Arguments is optional, but enableInspector indexed it whenever ArgumentsCount was above one. Stop at a nil array, and at a null element the way a C argv reader does, so the count alone can no longer make debug startup dereference an invalid pointer. --- NativeScript/inspector/JsV8InspectorClient.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NativeScript/inspector/JsV8InspectorClient.mm b/NativeScript/inspector/JsV8InspectorClient.mm index 7af9b0c6..9ba674ed 100644 --- a/NativeScript/inspector/JsV8InspectorClient.mm +++ b/NativeScript/inspector/JsV8InspectorClient.mm @@ -181,7 +181,9 @@ bool ShouldRewriteSourceMapURLs() { notify_post(NOTIFICATION("AppLaunching")); - for (int i = 1; i < argc; i++) { + // A nil Arguments array carries no flags whatever ArgumentsCount says, and a + // null element ends the list the way it does in a C argv. + for (int i = 1; argv != nullptr && i < argc && argv[i] != nullptr; i++) { BOOL startListening = NO; BOOL shouldWaitForDebugger = NO;