diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-06-11 16:52:09 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2015-08-06 12:22:28 +0200 |
commit | d0d07b079a31fb4412a57cb45a3d3e74658af27b (patch) | |
tree | 701ca8c3958dad92ac55d89af101db559a532405 /sc/inc | |
parent | a4b90bd12bdc0b133601c7e49d348ea0eec89bcb (diff) |
Resolves: tdf#89643 report builder function wizard segfaults
regression from
commit 3d6521280929ecacc53b7c358d29d0b5d31b3462
CommitDate: Thu Jul 31 22:14:25 2014 +0200
fix memory leak around function descriptions
Found by Lsan.
There are two implementations of getCategory, one (sc) returns a new one each
time (hence the leak fix) and the other (reportdesign) returns a pointer to one
that belongs to the manger (hence the crash).
The code in formula really looks to me to expect that the getCategory return a
pointer that "someone else" needs to look after, i.e. the reportdesign variant
is the more correct so revert 3d6521280929ecacc53b7c358d29d0b5d31b3462 and to
fix the leak make the sc own the ScFunctionCategories and just cache them like
the reportdesign one does
Change-Id: Ifd986301a54b4d20449e864697655cd973e0c4df
(cherry picked from commit 7c3abee29c742593206b755b20a718c46f0780fa)
Diffstat (limited to 'sc/inc')
-rw-r--r-- | sc/inc/funcdesc.hxx | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx index e746462e426d..43e4101c59b7 100644 --- a/sc/inc/funcdesc.hxx +++ b/sc/inc/funcdesc.hxx @@ -27,6 +27,7 @@ #include <formula/IFunctionDescription.hxx> #include <sal/types.h> #include <rtl/ustring.hxx> +#include <map> #define MAX_FUNCCAT 12 /* maximum number of categories for functions */ #define LRU_MAX 10 /* maximal number of last recently used functions */ @@ -361,7 +362,7 @@ public: /** Returns a category. - Creates an IFunctionCategory object from a category specified by nPos. + Returns an IFunctionCategory object for a category specified by nPos. @param nPos the index of the category, note that 0 maps to the first category not the cumulative ('All') category. @@ -399,9 +400,10 @@ public: private: ScFunctionList* pFuncList; /**< list of all calc functions */ - ::std::vector<const ScFuncDesc*>* aCatLists[MAX_FUNCCAT]; /**< array of all categories, 0 is the cumulative ('All') category */ - mutable ::std::vector<const ScFuncDesc*>::iterator pCurCatListIter; /**< position in current category */ - mutable ::std::vector<const ScFuncDesc*>::iterator pCurCatListEnd; /**< end of current category */ + std::vector<const ScFuncDesc*>* aCatLists[MAX_FUNCCAT]; /**< array of all categories, 0 is the cumulative ('All') category */ + mutable std::map< sal_uInt32, std::shared_ptr<ScFunctionCategory> > m_aCategories; /**< map of category pos to IFunctionCategory */ + mutable std::vector<const ScFuncDesc*>::iterator pCurCatListIter; /**< position in current category */ + mutable std::vector<const ScFuncDesc*>::iterator pCurCatListEnd; /**< end of current category */ }; #endif // INCLUDED_SC_INC_FUNCDESC_HXX |