Fixed segfault when cache is broken #213

This commit is contained in:
Scoopta 2024-02-11 20:30:12 -08:00
parent 39ac8366fe
commit 10c2a2a2d0
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
project('wofi', 'c', version : 'v1.4.1', default_options : ['c_std=c99', 'buildtype=release', 'warning_level=2'])
project('wofi', 'c', version : 'hg', default_options : ['c_std=c99', 'buildtype=release', 'warning_level=2'])
cc = meson.get_compiler('c')
pkgcfg = import('pkgconfig')

View File

@ -926,7 +926,16 @@ struct wl_list* wofi_read_cache(struct mode* mode) {
smallest_node = node;
}
}
char* tmp = strdup(strchr(smallest_node->line, ' ') + 1);
char* space = strchr(smallest_node->line, ' ');
if(space == NULL) {
free(smallest_node->line);
wl_list_remove(&smallest_node->link);
continue;
}
char* tmp = strdup(space + 1);
free(smallest_node->line);
smallest_node->line = tmp;
wl_list_remove(&smallest_node->link);