FLTK logo

[master] 9bf2726 - Fix "Native Filechooser (Zenity) crashes on second invocation" (#665)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 9bf2726 - Fix "Native Filechooser (Zenity) crashes on second invocation" (#665) "ManoloFLTK" Jan 31, 2023  
 
commit 9bf2726bce637d151bae133c072ac83e5f2ab514
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Tue Jan 31 13:13:48 2023 +0100
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Tue Jan 31 13:13:48 2023 +0100

     Fix "Native Filechooser (Zenity) crashes on second invocation" (#665)

 src/Fl_Native_File_Chooser_Kdialog.cxx | 1 -
 src/Fl_Native_File_Chooser_Zenity.cxx  | 4 +++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git src/Fl_Native_File_Chooser_Kdialog.cxx src/Fl_Native_File_Chooser_Kdialog.cxx
index b2c1008..db17d15 100644
--- src/Fl_Native_File_Chooser_Kdialog.cxx
+++ src/Fl_Native_File_Chooser_Kdialog.cxx
@@ -170,7 +170,6 @@ int Fl_Kdialog_Native_File_Chooser_Driver::show() {
     }
   }
   delete[] command;
-  if (_title) { free(_title); _title = NULL; }
   if (!pipe) return -1;
   return (data.all_files == NULL ? 1 : 0);
 }
diff --git src/Fl_Native_File_Chooser_Zenity.cxx src/Fl_Native_File_Chooser_Zenity.cxx
index ae972de..0f79301 100644
--- src/Fl_Native_File_Chooser_Zenity.cxx
+++ src/Fl_Native_File_Chooser_Zenity.cxx
@@ -77,7 +77,8 @@ char *Fl_Zenity_Native_File_Chooser_Driver::build_command() {
   snprintf(command+l, lcommand-l, " %s %s ", option, preset ? preset : "");
   delete[] preset;
   if (_parsedfilt) {
-    char *p = strtok(_parsedfilt, "\n");
+    char *parsed_filter_copy = strdup(_parsedfilt); // keep _parsedfilt unchanged for re-use
+    char *p = strtok(parsed_filter_copy, "\n");
     while (p) {
       char *op = strchr(p, '(');
       l = strlen(command);
@@ -105,6 +106,7 @@ char *Fl_Zenity_Native_File_Chooser_Driver::build_command() {
       }
       p = strtok(NULL, "\n");
     }
+    free(parsed_filter_copy);
   }
   strcat(command, " 2> /dev/null"); // get rid of stderr output
 //puts(command);
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.