aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil Hodgson <nyamatongwe@gmail.com>2014-03-26 11:25:19 +1100
committerNeil Hodgson <nyamatongwe@gmail.com>2014-03-26 11:25:19 +1100
commitb64c296768de37dd2ed30a34ec7888e35fc13532 (patch)
treed2f717667eb3c438518cb992d731d9ef7156a3e6
parented404335a35853d9250c703a3f28acde63b9b20d (diff)
downloadscintilla-mirror-b64c296768de37dd2ed30a34ec7888e35fc13532.tar.gz
Do not call AddCharUTF for empty insertions as may crash when autocompletion active
or cause other unexpected behaviour.
-rw-r--r--cocoa/ScintillaCocoa.mm11
1 files changed, 7 insertions, 4 deletions
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<UInt8> buffer(usedLen);
+ if (usedLen > 0)
+ {
+ std::vector<UInt8> 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<unsigned int>(usedLen), false);
+ AddCharUTF((char*) buffer.data(), static_cast<unsigned int>(usedLen), false);
+ }
return static_cast<int>(usedLen);
}