diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-05-22 15:14:40 +0200 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2011-05-23 11:28:40 +0200 |
commit | a8d1349bf5d84fc7170a80813d4edcf562184d48 (patch) | |
tree | 6ec6e9c0b2ea3e35f47293f5eb3e0c72833ee50e /svx | |
parent | ff6d8de3ee8700b8bb6511bc09897e248d631802 (diff) |
fdo#35728: fix GridControl crash
* various forms.OGridControlModel tests segfaulted
* root cause is the migration to stl containers in DbGridControl
* the old tools container returned the removed pointer or NULL causing no failure
* a signed int was used as index while the functions returned a unsigned int
* the GRID_COLUMN_NOT_FOUND magic value was out of the signed range
Diffstat (limited to 'svx')
-rw-r--r-- | svx/inc/svx/gridctrl.hxx | 2 | ||||
-rw-r--r-- | svx/source/fmcomp/gridctrl.cxx | 14 |
2 files changed, 8 insertions, 8 deletions
diff --git a/svx/inc/svx/gridctrl.hxx b/svx/inc/svx/gridctrl.hxx index 1a2917b89734..cbdba4004550 100644 --- a/svx/inc/svx/gridctrl.hxx +++ b/svx/inc/svx/gridctrl.hxx @@ -116,7 +116,7 @@ public: virtual void columnChanged() = 0; }; -#define GRID_COLUMN_NOT_FOUND ((sal_uInt16)-1) +#define GRID_COLUMN_NOT_FOUND SAL_MAX_UINT16 //================================================================== // InitWindowFacet, describing which aspect of a column's Window to (re-)initialize diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx index e6b050024d1d..d8fce64cadf6 100644 --- a/svx/source/fmcomp/gridctrl.cxx +++ b/svx/source/fmcomp/gridctrl.cxx @@ -1722,13 +1722,13 @@ sal_uInt16 DbGridControl::AppendColumn(const XubString& rName, sal_uInt16 nWidth //------------------------------------------------------------------------------ void DbGridControl::RemoveColumn(sal_uInt16 nId) { - sal_Int16 nIndex = GetModelColumnPos(nId); - DbGridControl_Base::RemoveColumn(nId); - - delete m_aColumns[ nIndex ]; - DbGridColumns::iterator it = m_aColumns.begin(); - ::std::advance( it, nIndex ); - m_aColumns.erase( it ); + const sal_uInt16 nIndex = GetModelColumnPos(nId); + if(nIndex != GRID_COLUMN_NOT_FOUND) + { + DbGridControl_Base::RemoveColumn(nId); + delete m_aColumns[nIndex]; + m_aColumns.erase( m_aColumns.begin()+nIndex ); + } } //------------------------------------------------------------------------------ |