From f93ba6a41ca8340a8fbd0ba8c96469cfa1f81aaa Mon Sep 17 00:00:00 2001 From: Scoopta Date: Sun, 20 Dec 2020 00:54:17 -0800 Subject: [PATCH] drun should no longer crash when encountering invalid cache entries --- modes/drun.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modes/drun.c b/modes/drun.c index 487487e..d599695 100644 --- a/modes/drun.c +++ b/modes/drun.c @@ -180,6 +180,9 @@ static struct widget_builder* populate_actions(char* file, size_t* text_count) { static char* get_id(char* path) { char* applications = strstr(path, "applications/"); + if(applications == NULL) { + return NULL; + } char* name = strchr(applications, '/') + 1; char* id = strdup(name); @@ -192,6 +195,10 @@ static char* get_id(char* path) { static struct widget* create_widget(char* full_path) { char* id = get_id(full_path); + if(id == NULL) { + free(full_path); + return NULL; + } if(map_contains(entries, id)) { free(id); @@ -231,6 +238,10 @@ static void insert_dir(char* app_dir) { } char* full_path = utils_concat(3, app_dir, "/", entry->d_name); char* id = get_id(full_path); + if(id == NULL) { + free(full_path); + continue; + } struct stat info; stat(full_path, &info);