osdialog_gtk2.c mixes std allocation and gtk allocation
RicoP opened this issue · 1 comments
RicoP commented
I saw that in osdialog_gtk2.c we return a string that is allocated with gtk_file_chooser_get_filename
char *result = NULL;
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
result = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
}
when we return this string directly we are in danger that on a later point we might try to deallocate the result with std::free.
The problem is that gtk uses it's own memory management, and mixing g_malloc and regular free leads to issues.
I would recommend copying the result string with strdup and deallocating the previous string with g_free before returning.
Also see: https://mail.gnome.org/archives/gtk-list/2000-July/msg00002.html
AndrewBelt commented
Thanks, fixed in 65a3b2e