From b64c296768de37dd2ed30a34ec7888e35fc13532 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Wed, 26 Mar 2014 11:25:19 +1100 Subject: Do not call AddCharUTF for empty insertions as may crash when autocompletion active or cause other unexpected behaviour. --- cocoa/ScintillaCocoa.mm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cocoa') diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 1e9d6e973..f9e67f7b4 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -1925,12 +1925,15 @@ int ScintillaCocoa::InsertText(NSString* input) CFStringGetBytes((CFStringRef)input, rangeAll, encoding, '?', false, NULL, 0, &usedLen); - std::vector buffer(usedLen); + if (usedLen > 0) + { + std::vector buffer(usedLen); - CFStringGetBytes((CFStringRef)input, rangeAll, encoding, '?', - false, buffer.data(),usedLen, NULL); + CFStringGetBytes((CFStringRef)input, rangeAll, encoding, '?', + false, buffer.data(),usedLen, NULL); - AddCharUTF((char*) buffer.data(), static_cast(usedLen), false); + AddCharUTF((char*) buffer.data(), static_cast(usedLen), false); + } return static_cast(usedLen); } -- cgit v1.2.3