Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sat, 25 Oct 2014 15:46:50 UTC Commit: b7b4677d6ba5b3d27aeecae613bccd465b2b1335 https://github.com/geany/geany-plugins/commit/b7b4677d6ba5b3d27aeecae613bccd...
Log Message: ----------- debugger: Consolidate code for selecting the target file
This fixes a leak, a possible NULL-pointer dereference and buffer overflows.
Modified Paths: -------------- debugger/src/tpage.c
Modified: debugger/src/tpage.c 17 lines changed, 9 insertions(+), 8 deletions(-) =================================================================== @@ -97,10 +97,10 @@ static void on_arguments_changed(GtkTextBuffer *textbuffer, gpointer user_data) */ static void on_target_browse_clicked(GtkButton *button, gpointer user_data) { - gchar path[FILENAME_MAX]; + gchar *path; const gchar *prevfile; - gchar *prevdir; GtkWidget *dialog; + GeanyDocument *doc;
dialog = gtk_file_chooser_dialog_new (_("Choose target file"), NULL, @@ -110,14 +110,15 @@ static void on_target_browse_clicked(GtkButton *button, gpointer user_data) NULL); prevfile = gtk_entry_get_text(GTK_ENTRY(target_name)); - prevdir = g_path_get_dirname(prevfile); - if (strcmp(".", prevdir)) - strcpy(path, prevdir); - else - strcpy(path, g_path_get_dirname(DOC_FILENAME(document_get_current()))); - g_free(prevdir); + path = g_path_get_dirname(prevfile); + if (strcmp(".", path) == 0 && (doc = document_get_current()) != NULL) + { + g_free(path); + path = g_path_get_dirname(DOC_FILENAME(doc)); + } gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), path); + g_free(path); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).