Project

General

Profile

Actions

Bug #1679

closed

WStringListModel removeRows can cause segmentation fault (development version)

Added by Bruce Toll almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Priority:
Low
Assignee:
-
Target version:
Start date:
02/08/2013
Due date:
% Done:

0%

Estimated time:

Description

The attached test program results in the following gdb backtrace (simplified):

Program received signal SIGSEGV, Segmentation fault.
#0 in __gnu_cxx::__normal_iterator<std::map<int, boost::any, std::less<int>, std::allocator<std::pair<int const, boost::any> > >*, std::vector<std::map<int, boost::any, std::less<int>, std::allocator<std::pair<int const, boost::any> > >, std::allocator<std::map<int, boost::any, std::less<int>, std::allocator<std::pair<int const, boost::any> > > > > >::__normal_iterator (
    , __i=@0x0: <error reading variable>) at /usr/include/c++/4.7/bits/stl_iterator.h:728
#1 in std::vector<std::map<int, boost::any, std::less<int>, std::allocator<std::pair<int const, boost::any> > >, std::allocator<std::map<int, boost::any, std::less<int>, std::allocator<std::pair<int const, boost::any> > > > >::begin (this=0x0) at /usr/include/c++/4.7/bits/stl_vector.h:519
#2 in Wt::WStringListModel::removeRows (this=0x64f0f0, row=0, count=1, parent=...) at wt-3.3.0-pre-js-debug/src/Wt/WStringListModel.C:171
#3 in SmTestApplication::SmTestApplication (this=0x649d30, env=...) at string_list_model_remove_20130208a.cc:25
#4 in createApplication (env=...) at string_list_model_remove_20130208a.cc:31

Bug 1671 may be related.

The following patch seems to help:

diff a/src/Wt/WStringListModel.C b/src/Wt/WStringListModel.C
--- a/src/Wt/WStringListModel.C
+++ b/src/Wt/WStringListModel.C
@@ -167,8 +167,9 @@ bool WStringListModel::removeRows(int row, int count, const WModelIndex& parent)
     beginRemoveRows(parent, row, row + count - 1);
     displayData_.erase(displayData_.begin() + row,
                       displayData_.begin() + row + count);
-    otherData_->erase(otherData_->begin() + row,
-                     otherData_->begin() + row + count);
+    if (otherData_)
+      otherData_->erase(otherData_->begin() + row,
+                        otherData_->begin() + row + count);
     endRemoveRows();

     return true;

Files

Actions #1

Updated by Koen Deforche almost 12 years ago

  • Status changed from New to Resolved

Hey Bruce,

I just ran in the same problem and with the same conclusion last night !

Thanks for spotting it.

Regards,

koen

Actions #2

Updated by Koen Deforche almost 12 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF