diff options
author | Érico Rolim <erico.erc@gmail.com> | 2020-10-22 03:47:15 -0300 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2020-11-16 22:12:07 +0000 |
commit | 489421b9e763865881df614a3ef550b289409677 (patch) | |
tree | f67345f16496d194d299fba3de5a41489a932eec | |
parent | 6cb2b8495f0da310acf8779db47a3317e9c54707 (diff) | |
download | imv-489421b9e763865881df614a3ef550b289409677.tar.gz |
imv, ipc: improve error checking for ipc creation.
Since this isn't essential functionality, it's ok to simply not provide
it. In cases where XDG_RUNTIME_DIR was empty (but not unset) or set to a
directory where the user didn't have write permissions, socket creation
would fail and lead to segmentation faults in imv, due to the return
value of imv_ipc_create() not being checked.
-rw-r--r-- | src/imv.c | 4 | ||||
-rw-r--r-- | src/ipc.c | 3 |
2 files changed, 6 insertions, 1 deletions
@@ -533,7 +533,9 @@ struct imv *imv_create(void) imv->console = imv_console_create(); imv_console_set_command_callback(imv->console, &command_callback, imv); imv->ipc = imv_ipc_create(); - imv_ipc_set_command_callback(imv->ipc, &command_callback, imv); + if (imv->ipc) { + imv_ipc_set_command_callback(imv->ipc, &command_callback, imv); + } imv->title_text = strdup( "imv - [${imv_current_index}/${imv_file_count}]" " [${imv_width}x${imv_height}] [${imv_scale}%]" @@ -92,6 +92,9 @@ struct imv_ipc *imv_ipc_create(void) } struct imv_ipc *ipc = calloc(1, sizeof *ipc); + if (ipc == NULL) { + return NULL; + } ipc->fd = sockfd; pthread_t thread; |