From 051274b960289e446bcba51389728955ac26c87f Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 16 Jul 2012 17:04:25 -0400 Subject: [PATCH] Bug - Fixed bug that caused a segfault when an invalid sort column was specified (thanks to Uli Martens). --- src/sort.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sort.cpp b/src/sort.cpp index cb268a408..2162176ed 100644 --- a/src/sort.cpp +++ b/src/sort.cpp @@ -34,6 +34,7 @@ #include #include #include +#include extern Context context; @@ -72,6 +73,8 @@ static bool sort_compare (int left, int right) std::string field; bool ascending; + Column* column; + int left_number; int right_number; float left_real; @@ -239,9 +242,9 @@ static bool sort_compare (int left, int right) } // UDAs. - else + else if ((column = context.columns[field]) != NULL) { - std::string type = context.columns[field]->type (); + std::string type = column->type (); if (type == "numeric") { left_real = (*global_data)[left].urgency (); @@ -297,6 +300,8 @@ static bool sort_compare (int left, int right) return left_duration > right_duration; } } + else + throw format (STRING_INVALID_SORT_COL, field); } return false;