2 Commits
Author SHA1 Message Date
rabfulton effa685762 Merge pull request #1 from FenrirTheGray/fix/reload-file-crash
Fix error when reloading file more than once
2026-04-10 11:28:26 +01:00
Aleksandar Colovic a30ce043f4 Fix crash when reloading file more than once
markyd_app_open_file() invalidates the current path string, so calling
it with the pointer from markyd_app_get_current_path() works the first
time but causes a use-after-free on subsequent reloads. Copy the path
with g_strdup() before passing it to open_file, and free it afterwards.
2026-04-08 18:46:24 +02:00
+6 -3
View File
@@ -965,15 +965,17 @@ static void on_open_clicked(GtkButton *button, gpointer user_data) {
static void on_refresh_clicked(GtkButton *button, gpointer user_data) {
MarkydWindow *self = (MarkydWindow *)user_data;
const gchar *path;
const gchar *current;
gchar *path;
(void)button;
path = markyd_app_get_current_path(self->app);
if (!path || path[0] == '\0') {
current = markyd_app_get_current_path(self->app);
if (!current || current[0] == '\0') {
return;
}
path = g_strdup(current);
if (!markyd_app_open_file(self->app, path)) {
GtkWidget *error_dialog = gtk_message_dialog_new(
GTK_WINDOW(self->window),
@@ -984,6 +986,7 @@ static void on_refresh_clicked(GtkButton *button, gpointer user_data) {
gtk_dialog_run(GTK_DIALOG(error_dialog));
gtk_widget_destroy(error_dialog);
}
g_free(path);
}
static void on_settings_clicked(GtkButton *button, gpointer user_data) {