From b787fad2f9615961257f896dbb28bcff9efab913 Mon Sep 17 00:00:00 2001 From: laomuon Date: Fri, 9 Aug 2024 03:15:24 +0200 Subject: [PATCH] fix: free current_index_path when close docs or set to a new one --- zathura/utils.c | 1 + zathura/zathura.c | 3 +++ zathura/zathura.h | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/zathura/utils.c b/zathura/utils.c index ec25be68..28b1641d 100644 --- a/zathura/utils.c +++ b/zathura/utils.c @@ -142,6 +142,7 @@ void index_scroll_to_current_page(zathura_t* zathura) { gtk_tree_model_foreach(model, search_current_index, &search_data); GtkTreePath* current_path = gtk_tree_model_get_path(model, &search_data.current_iter); + g_free(zathura->global.current_index_path); zathura->global.current_index_path = gtk_tree_path_to_string(current_path); gtk_tree_view_expand_to_path(tree_view, current_path); diff --git a/zathura/zathura.c b/zathura/zathura.c index 244989f7..5b21ea07 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -1513,6 +1513,9 @@ bool document_close(zathura_t* zathura, bool keep_monitor) { zathura->ui.index = NULL; } + /* free current index path */ + g_free(zathura->global.current_index_path); + gtk_widget_hide(zathura->ui.page_widget); statusbar_page_number_update(zathura); diff --git a/zathura/zathura.h b/zathura/zathura.h index 604246ff..21f7da92 100644 --- a/zathura/zathura.h +++ b/zathura/zathura.h @@ -139,7 +139,7 @@ struct zathura_s { GdkModifierType synctex_edit_modmask; /**< Modifier to trigger synctex edit */ GdkModifierType highlighter_modmask; /**< Modifier to draw with a highlighter */ bool double_click_follow; /**< Double/Single click to follow link */ - char *current_index_path; + gchar *current_index_path; } global; struct {