summaryrefslogtreecommitdiff
path: root/ui/qt/packet_list_model.cpp
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-10-22 23:29:56 +0200
committerAnders Broman <a.broman58@gmail.com>2016-10-24 04:33:00 +0000
commit3b502c873f2b30e661d46693d3a3f6fcba9474ea (patch)
treed0ef42dd38f4f8b61a9fa8d432fb96a1d58abdb0 /ui/qt/packet_list_model.cpp
parent20e2edca572a835ab4ee6ff1fbbf86bf5db54b35 (diff)
downloadwireshark-3b502c873f2b30e661d46693d3a3f6fcba9474ea.tar.gz
Qt: fix possible crash on sorting custom columns
The sorting function must maintain a strict weak ordering, otherwise it may result in crashes. In the case of custom columns, this was violated when exactly one of the two rows had a non-numeric value. Bug: 13023 Change-Id: Ie338b1cce5156eeb313dd33491ee3d3f2eaddf1c Reviewed-on: https://code.wireshark.org/review/18406 Reviewed-by: Jim Young <jim.young.ws@gmail.com> Petri-Dish: Jim Young <jim.young.ws@gmail.com> Tested-by: Jim Young <jim.young.ws@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/qt/packet_list_model.cpp')
-rw-r--r--ui/qt/packet_list_model.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/ui/qt/packet_list_model.cpp b/ui/qt/packet_list_model.cpp
index 080a09cd81..4c8012ea91 100644
--- a/ui/qt/packet_list_model.cpp
+++ b/ui/qt/packet_list_model.cpp
@@ -417,9 +417,11 @@ bool PacketListModel::recordLessThan(PacketListRecord *r1, PacketListRecord *r2)
if (!ok_r1 && !ok_r2) {
cmp_val = 0;
- } else if (!ok_r1 || num_r1 < num_r2) {
+ } else if (!ok_r1 || (ok_r2 && num_r1 < num_r2)) {
+ // either r1 is invalid (and sort it before others) or both
+ // r1 and r2 are valid (sort normally)
cmp_val = -1;
- } else if (!ok_r2 || num_r1 > num_r2) {
+ } else if (!ok_r2 || (ok_r1 && num_r1 > num_r2)) {
cmp_val = 1;
}
} else {