Qt: initialize all UAT fields when creating a new line
authorPascal Quantin <pascal.quantin@gmail.com>
Tue, 27 Oct 2015 22:55:13 +0000 (23:55 +0100)
committerPascal Quantin <pascal.quantin@gmail.com>
Wed, 28 Oct 2015 13:58:09 +0000 (13:58 +0000)
Otherwise it can trigger a crash when calling the callback while some fields have a NULL pointer (SSL post_update_cb for example)

Change-Id: I25ac97d8e0bbf47e737f74029715358cb29cfb3d
Reviewed-on: https://code.wireshark.org/review/11334
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
ui/qt/uat_dialog.cpp

index 25c3409bd2a5b377f895ed8355e6f16f0907069a..141e20bfacd186478b36130a5ccc2406b12303a6 100644 (file)
@@ -484,12 +484,19 @@ void UatDialog::addRecord(bool copy_from_current)
     } else {
         for (guint col = 0; col < uat_->ncols; col++) {
             uat_field_t *field = &uat_->fields[col];
-            if (field->mode == PT_TXTMOD_ENUM) {
+            switch (field->mode) {
+            case PT_TXTMOD_ENUM:
                 guint length;
                 const char *str;
                 field->cb.tostr(rec, &str, &length, field->cbdata.tostr, field->fld_data);
                 field->cb.set(rec, str, length, field->cbdata.set, field->fld_data);
                 g_free((char*)str);
+                break;
+            case PT_TXTMOD_NONE:
+                break;
+            default:
+                field->cb.set(rec, "", 0, field->cbdata.set, field->fld_data);
+                break;
             }
         }
     }