From e7bd1767be9ab396c53d39f6e832cffeca73edbc Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Fri, 12 Apr 2019 21:10:23 -0700 Subject: [PATCH] Add null check in FLETextInputPlugin (flutter/engine#8538) Adds a guard on `_activeClientID` in `insertNewline:`. The conditional around the `insertText:replacementRange:` call already catches this, but we then unconditionally pack `_activeClientID` into an `NSArray`, which disallows nil. --- .../macos/framework/Source/FLETextInputPlugin.mm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.mm index 25079d565c0..9a2226054f2 100644 --- a/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FLETextInputPlugin.mm @@ -242,11 +242,13 @@ static NSString* const kMultilineInputType = @"TextInputType.multiline"; } - (void)insertNewline:(id)sender { - if ([self.activeModel.inputType isEqualToString:kMultilineInputType]) { - [self insertText:@"\n" replacementRange:self.activeModel.selectedRange]; + if (self.activeModel != nil) { + if ([self.activeModel.inputType isEqualToString:kMultilineInputType]) { + [self insertText:@"\n" replacementRange:self.activeModel.selectedRange]; + } + [_channel invokeMethod:kPerformAction + arguments:@[ _activeClientID, self.activeModel.inputAction ]]; } - [_channel invokeMethod:kPerformAction - arguments:@[ _activeClientID, self.activeModel.inputAction ]]; } - (void)setMarkedText:(id)string