From 1545e3140dea98a3f374878436c35109727785af Mon Sep 17 00:00:00 2001 From: augustin64 Date: Mon, 17 Jul 2023 09:45:38 +0200 Subject: [PATCH] main:Fix segfault when socket does not exist --- src/main/db.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/db.c b/src/main/db.c index 33514ab..bbe8490 100644 --- a/src/main/db.c +++ b/src/main/db.c @@ -79,13 +79,16 @@ sqlite3* get_db() { void notify_change() { char* socket_path = get_socket_path(); - FILE* fp = fopen(socket_path, "r"); - - int pid; - fscanf(fp, "%d", &pid); // Trigger IN_ACCESS - (void)pid; + if (access(socket_path, F_OK) == 0) { + FILE* fp = fopen(socket_path, "r"); - fclose(fp); + int pid; + fscanf(fp, "%d", &pid); // Trigger IN_ACCESS + (void)pid; + + fclose(fp); + } + free(socket_path); }