Replace scalloc + strncpy with sstrndup

This commit is contained in:
Orestis Floros
2019-03-30 13:20:32 +02:00
parent 8903f29795
commit ea6068a02d
2 changed files with 7 additions and 11 deletions

View File

@ -215,12 +215,11 @@ void ipc_shutdown(shutdown_reason_t reason) {
IPC_HANDLER(run_command) {
/* To get a properly terminated buffer, we copy
* message_size bytes out of the buffer */
char *command = scalloc(message_size + 1, 1);
strncpy(command, (const char *)message, message_size);
char *command = sstrndup((const char *)message, message_size);
LOG("IPC: received: *%s*\n", command);
yajl_gen gen = yajl_gen_alloc(NULL);
CommandResult *result = parse_command((const char *)command, gen);
CommandResult *result = parse_command(command, gen);
free(command);
if (result->needs_tree_render)