mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
common: ipc_single_command can return NULL
Especially printf's %s with NULL value is undefined behavior.
This commit is contained in:
parent
06ab0d166a
commit
3e69928f13
4 changed files with 22 additions and 5 deletions
|
|
@ -478,6 +478,14 @@ int main(int argc, char **argv) {
|
|||
ipc_set_recv_timeout(socketfd, timeout);
|
||||
size_t len = strlen(command);
|
||||
char *resp = ipc_single_command(socketfd, type, command, &len);
|
||||
if (resp == NULL) {
|
||||
if (!quiet) {
|
||||
sway_log(SWAY_ERROR, "Failed to receive reply");
|
||||
}
|
||||
close(socketfd);
|
||||
free(socket_path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// pretty print the json
|
||||
json_object *obj = json_tokener_parse(resp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue