Cleanup: replace strncpy with memcpy for buffers of a known size
This commit is contained in:
parent
8f8a9ef488
commit
0bf7d15fa6
@ -338,14 +338,14 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar)
|
||||
|
||||
#define FIRSTFILEBUFLG 512
|
||||
static bool g_hasFirstFile = false;
|
||||
static char g_firstFileBuf[512];
|
||||
static char g_firstFileBuf[FIRSTFILEBUFLG];
|
||||
|
||||
// TODO: Need to investigate this.
|
||||
// Function called too early in creator.c to have g_hasFirstFile == true
|
||||
/* TODO: Need to investigate this.
|
||||
* Function called too early in creator.c to have g_hasFirstFile == true */
|
||||
extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
|
||||
{
|
||||
if (g_hasFirstFile) {
|
||||
strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
|
||||
memcpy(buf, g_firstFileBuf, FIRSTFILEBUFLG);
|
||||
buf[FIRSTFILEBUFLG - 1] = '\0';
|
||||
return 1;
|
||||
}
|
||||
@ -1239,9 +1239,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
||||
break;
|
||||
}
|
||||
|
||||
strncpy((char *)temp_buff,
|
||||
[droppedStr cStringUsingEncoding:NSUTF8StringEncoding],
|
||||
pastedTextSize);
|
||||
memcpy(
|
||||
temp_buff, [droppedStr cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize);
|
||||
temp_buff[pastedTextSize] = '\0';
|
||||
|
||||
strArray->strings[i] = temp_buff;
|
||||
@ -1260,10 +1259,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
strncpy((char *)temp_buff,
|
||||
[droppedStr cStringUsingEncoding:NSUTF8StringEncoding],
|
||||
pastedTextSize);
|
||||
|
||||
memcpy(
|
||||
temp_buff, [droppedStr cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize);
|
||||
temp_buff[pastedTextSize] = '\0';
|
||||
|
||||
eventData = (GHOST_TEventDataPtr)temp_buff;
|
||||
@ -1469,7 +1466,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
strncpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize);
|
||||
memcpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize);
|
||||
temp_buff[filenameTextSize] = '\0';
|
||||
|
||||
pushEvent(new GHOST_EventString(
|
||||
@ -2024,8 +2021,7 @@ char *GHOST_SystemCocoa::getClipboard(bool /*selection*/) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
strncpy(temp_buff, [textPasted cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize);
|
||||
|
||||
memcpy(temp_buff, [textPasted cStringUsingEncoding:NSUTF8StringEncoding], pastedTextSize);
|
||||
temp_buff[pastedTextSize] = '\0';
|
||||
|
||||
if (temp_buff) {
|
||||
|
Loading…
Reference in New Issue
Block a user