Avoid buffer overrun by not using depreciated getCharacters method. Use getCharacters:range instead.

Cinders 2013-09-18 03:41:48 -06:00
parent 7e92a24279
commit 7f50860af0
2 changed files with 6 additions and 5 deletions

View File

@ -91,10 +91,11 @@ const unsigned short *copyFromPBoard()
NSArray *objToPaste = [pboard readObjectsForClasses:classArray options:[NSDictionary dictionary]];
str = [objToPaste objectAtIndex:0];
}
unichar* temp = (unichar*)calloc([str length], sizeof(unichar));
[str getCharacters:temp];
NSUInteger len = [str length];
unichar* buffer = (unichar*)calloc(len, sizeof(unichar));
[str getCharacters:buffer range:NSMakeRange(0, len)];
[pool release];
return temp;
return buffer;
}
CursorRef createImageCursor(const char *fullpath, int hotspotX, int hotspotY)

View File

@ -1153,8 +1153,8 @@ BOOL LLWindowMacOSX::isClipboardTextAvailable()
BOOL LLWindowMacOSX::pasteTextFromClipboard(LLWString &dst)
{
llutf16string str(copyFromPBoard());
dst = utf16str_to_wstring(str);
//llutf16string str(copyFromPBoard());
dst = utf16str_to_wstring(copyFromPBoard());
LLWStringUtil::removeCRLF(dst); // <FS:CR>
if (dst != L"")
{