]> git.sur5r.net Git - i3/i3/blobdiff - src/ipc.c
Replace scalloc + strncpy with sstrndup
[i3/i3] / src / ipc.c
index 2432d7a543451a2059521ca4e7456c330325f3de..e548b5a6eec4d769f18cfc20dbbc16ba4d29484a 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -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)