Create a properly 0-terminated string to avoid pasting unicode garbage.

Nicky 2014-04-07 17:51:18 +02:00
parent 5d6b81f360
commit 8ecffc2581
1 changed files with 6 additions and 1 deletions

View File

@ -92,7 +92,12 @@ const unsigned short *copyFromPBoard()
str = [objToPaste objectAtIndex:0];
}
NSUInteger len = [str length];
unichar* buffer = (unichar*)calloc(len, sizeof(unichar));
// <FS:ND> add+1 for 0-terminator.
// unichar* buffer = (unichar*)calloc(len, sizeof(unichar));
unichar* buffer = (unichar*)calloc(len+1, sizeof(unichar));
// </FS:ND>
[str getCharacters:buffer range:NSMakeRange(0, len)];
[pool release];
return buffer;