perf: Extra safety with strlen(cmd).

This commit is contained in:
Jerzy Jamroz
2025-02-04 15:20:05 +01:00
committed by Andrew Johnson
parent 8752372af1
commit 82994d600f

View File

@@ -58,7 +58,7 @@ static struct cmditem* newItem(char* cmd)
struct cmditem* item = mallocMustSucceed(sizeof(struct cmditem) + strlen(cmd) + 1,
__AT_INIT_LOG(ERL_ERROR) "failed to allocate memory for cmditem");
item->cmd = (char*)(item + 1);
strcpy(item->cmd, cmd);
memcpy(item->cmd, cmd, strlen(cmd) + 1);
if(item->cmd == NULL)
{