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
|
|
@ -344,6 +344,9 @@ bool ipc_get_workspaces(struct swaybar *bar) {
|
|||
size_t len = 0;
|
||||
char *res = ipc_single_command(bar->ipc_socketfd,
|
||||
IPC_GET_WORKSPACES, NULL, &len);
|
||||
if (res == NULL) {
|
||||
return false;
|
||||
}
|
||||
json_object *results = json_tokener_parse(res);
|
||||
if (!results) {
|
||||
free(res);
|
||||
|
|
@ -418,7 +421,7 @@ bool ipc_initialize(struct swaybar *bar) {
|
|||
size_t len = strlen(bar->id);
|
||||
char *res = ipc_single_command(bar->ipc_socketfd,
|
||||
IPC_GET_BAR_CONFIG, bar->id, &len);
|
||||
if (!ipc_parse_config(bar->config, res)) {
|
||||
if (res == NULL || !ipc_parse_config(bar->config, res)) {
|
||||
free(res);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue