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
|
|
@ -153,9 +153,15 @@ char *ipc_single_command(int socketfd, uint32_t type, const char *payload, size_
|
|||
}
|
||||
|
||||
struct ipc_response *resp = ipc_recv_response(socketfd);
|
||||
char *response = resp->payload;
|
||||
*len = resp->size;
|
||||
free(resp);
|
||||
char *response;
|
||||
if (resp == NULL) {
|
||||
response = NULL;
|
||||
*len = 0;
|
||||
} else {
|
||||
response = resp->payload;
|
||||
*len = resp->size;
|
||||
free(resp);
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue