Qt: don't append a second extension to save file names
authorРоман Донченко <dpb@corrigendum.ru>
Tue, 6 Dec 2016 22:14:39 +0000 (01:14 +0300)
committerGerald Combs <gerald@wireshark.org>
Wed, 7 Dec 2016 20:36:43 +0000 (20:36 +0000)
When checking if the file already has one of the possible extensions,
MainWindow::fileAddExtension reuses file_suffix between iterations and
appends to it each time, so it ends up checking for the wrong suffix for all
extensions except the first one. Scope file_suffix to the for loop to
fix that.

Change-Id: Idbc5a619a4793d8c477bfd88305cdb44ea844e13
Reviewed-on: https://code.wireshark.org/review/19123
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
ui/qt/main_window.cpp

index 506907917dd7bf54ab2ecef828a9d81465112676..d193dde99321e36b68232942f34c51253dec33bb 100644 (file)
@@ -1495,7 +1495,6 @@ void MainWindow::exportDissections(export_type_e export_type) {
 
 void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compressed) {
     QString file_name_lower;
-    QString file_suffix;
     GSList  *extensions_list;
     gboolean add_extension;
 
@@ -1516,7 +1515,7 @@ void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compre
         /* OK, see if the file has one of those extensions. */
         for (extension = extensions_list; extension != NULL;
              extension = g_slist_next(extension)) {
-            file_suffix += tr(".") + (char *)extension->data;
+            QString file_suffix = tr(".") + (char *)extension->data;
             if (file_name_lower.endsWith(file_suffix)) {
                 /*
                  * The file name has one of the extensions for