diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-08-01 14:50:54 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2014-08-04 12:49:59 +0000 |
commit | 02f0102b8bd7793ddd2fe7a54c46d41b9a608cec (patch) | |
tree | 681ab6c40925a32a71cc6361cf538bced70d7c23 /svx/source/sdr/properties/attributeproperties.cxx | |
parent | 4189b715999bf9ebb0cd04a0c610a7b514e28d1b (diff) |
prevent memory leak
Found by Lsan.
Returning this or a heap allocated object asks for trouble. Let the
caller handle it and return null instead of this.
Change-Id: I7586e103bef5a8c2727adfe214b052d6962d4467
Reviewed-on: https://gerrit.libreoffice.org/10716
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'svx/source/sdr/properties/attributeproperties.cxx')
-rw-r--r-- | svx/source/sdr/properties/attributeproperties.cxx | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx index d7665c86edec..454d7b974506 100644 --- a/svx/source/sdr/properties/attributeproperties.cxx +++ b/svx/source/sdr/properties/attributeproperties.cxx @@ -165,62 +165,60 @@ namespace sdr { if(pNewItem) { - const SfxPoolItem* pItem = pNewItem; + const SfxPoolItem* pResultItem = NULL; SdrModel* pModel = GetSdrObject().GetModel(); switch( nWhich ) { case XATTR_FILLBITMAP: { - pItem = ((XFillBitmapItem*)pItem)->checkForUniqueItem( pModel ); + pResultItem = ((XFillBitmapItem*)pNewItem)->checkForUniqueItem( pModel ); break; } case XATTR_LINEDASH: { - pItem = ((XLineDashItem*)pItem)->checkForUniqueItem( pModel ); + pResultItem = ((XLineDashItem*)pNewItem)->checkForUniqueItem( pModel ); break; } case XATTR_LINESTART: { - pItem = ((XLineStartItem*)pItem)->checkForUniqueItem( pModel ); + pResultItem = ((XLineStartItem*)pNewItem)->checkForUniqueItem( pModel ); break; } case XATTR_LINEEND: { - pItem = ((XLineEndItem*)pItem)->checkForUniqueItem( pModel ); + pResultItem = ((XLineEndItem*)pNewItem)->checkForUniqueItem( pModel ); break; } case XATTR_FILLGRADIENT: { - pItem = ((XFillGradientItem*)pItem)->checkForUniqueItem( pModel ); + pResultItem = ((XFillGradientItem*)pNewItem)->checkForUniqueItem( pModel ); break; } case XATTR_FILLFLOATTRANSPARENCE: { // #85953# allow all kinds of XFillFloatTransparenceItem to be set - pItem = ((XFillFloatTransparenceItem*)pItem)->checkForUniqueItem( pModel ); + pResultItem = ((XFillFloatTransparenceItem*)pNewItem)->checkForUniqueItem( pModel ); break; } case XATTR_FILLHATCH: { - pItem = ((XFillHatchItem*)pItem)->checkForUniqueItem( pModel ); + pResultItem = ((XFillHatchItem*)pNewItem)->checkForUniqueItem( pModel ); break; } } // set item - if(pItem) + GetObjectItemSet(); + if(pResultItem) { // force ItemSet - GetObjectItemSet(); - mpItemSet->Put(*pItem); - + mpItemSet->Put(*pResultItem); // delete item if it was a generated one - if(pItem != pNewItem) - { - delete (SfxPoolItem*)pItem; - } + delete (SfxPoolItem*)pResultItem; } + else + mpItemSet->Put(*pNewItem); } else { |