From 6d6fa3655e04cdddaf8caf380e356a8382cff425 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Thu, 19 Aug 2010 09:18:38 +0200 Subject: chart49: #i113722# duplicate chart creation - OSingleFactoryHelper::createInstanceWithArgumentsAndContext leak --- cppuhelper/source/factory.cxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cppuhelper/source/factory.cxx') diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index 96faf2272231..20adf05391b9 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -232,9 +232,17 @@ Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndCont else { if ( rArguments.getLength() ) + { + // dispose the here created UNO object before throwing out exception + // to avoid risk of memory leaks #i113722# + Reference xComp( xRet, UNO_QUERY ); + if (xComp.is()) + xComp->dispose(); + throw lang::IllegalArgumentException( OUString( RTL_CONSTASCII_USTRINGPARAM("cannot pass arguments to component => no XInitialization implemented!") ), Reference< XInterface >(), 0 ); + } } return xRet; -- cgit