mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 18:15:59 +01:00
more error handling
This commit is contained in:
parent
58e25e8733
commit
33173e018e
2 changed files with 9 additions and 6 deletions
13
completion.c
13
completion.c
|
@ -31,22 +31,21 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
|
|||
char* name = NULL;
|
||||
while ((name = (char*) g_dir_read_name(dir)) != NULL) {
|
||||
char* e_name = g_filename_display_name(name);
|
||||
int e_length = strlen(e_name);
|
||||
|
||||
if (e_name == NULL) {
|
||||
continue;
|
||||
goto error_free;
|
||||
}
|
||||
int e_length = strlen(e_name);
|
||||
|
||||
if ((current_file_length > e_length) || strncmp(current_file, e_name,
|
||||
current_file_length)) {
|
||||
g_free(e_name);
|
||||
continue;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
char* full_path = g_strdup_printf("%s%s%s", current_path, is_dir ? "" : "/", e_name);
|
||||
if (full_path == NULL) {
|
||||
g_free(e_name);
|
||||
continue;
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
if (g_file_test(full_path, G_FILE_TEST_IS_DIR) == true) {
|
||||
|
@ -64,6 +63,10 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
|
|||
|
||||
g_dir_close(dir);
|
||||
return res;
|
||||
|
||||
error_free:
|
||||
girara_list_free(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
girara_completion_t*
|
||||
|
|
|
@ -37,7 +37,7 @@ void
|
|||
zathura_document_plugins_load(zathura_t* zathura)
|
||||
{
|
||||
GIRARA_LIST_FOREACH(zathura->plugins.path, char*, iter, plugindir)
|
||||
|
||||
/* TODO: rewrite with GDir */
|
||||
/* read all files in the plugin directory */
|
||||
DIR* dir = opendir(plugindir);
|
||||
if (dir == NULL) {
|
||||
|
|
Loading…
Reference in a new issue