diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-03-31 15:35:36 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-04-03 07:27:34 +0000 |
commit | 4176d652a5aa31e6ea7a1be1798819ceb0d2b007 (patch) | |
tree | aa77cbb1f486d90a5768dc96eaf33394e20ed1da /sw | |
parent | 637f9ffa6317d7b06e562283f210f67ecafe9e42 (diff) |
sw: fix obscure crash in SwXTextDocument::getSomething()
xNumFmtAgg may be null if you directly call global ServiceManager's
createInstanceWithContext("com.sun.star.text.TextDocument")
Change-Id: Id619a3f5c9e3f8281f9ef72db132c64287e027c4
(cherry picked from commit d360477d8740f29e2c2bc5f7bbd667df7cd26ee9)
Reviewed-on: https://gerrit.libreoffice.org/15102
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 50dc5f895976..7b0b82c9b5f9 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -263,19 +263,16 @@ sal_Int64 SAL_CALL SwXTextDocument::getSomething( const Sequence< sal_Int8 >& rI } sal_Int64 nRet = SfxBaseModel::getSomething( rId ); - if ( nRet ) + if (nRet) return nRet; - else - { - GetNumberFormatter(); - Any aNumTunnel = xNumFmtAgg->queryAggregation(cppu::UnoType<XUnoTunnel>::get()); - Reference<XUnoTunnel> xNumTunnel; - aNumTunnel >>= xNumTunnel; - if(xNumTunnel.is()) - return xNumTunnel->getSomething(rId); - } - return SfxBaseModel::getSomething( rId ); + GetNumberFormatter(); + if (!xNumFmtAgg.is()) // may happen if not valid or no SwDoc + return 0; + Any aNumTunnel = xNumFmtAgg->queryAggregation(cppu::UnoType<XUnoTunnel>::get()); + Reference<XUnoTunnel> xNumTunnel; + aNumTunnel >>= xNumTunnel; + return (xNumTunnel.is()) ? xNumTunnel->getSomething(rId) : 0; } Any SAL_CALL SwXTextDocument::queryInterface( const uno::Type& rType ) throw(RuntimeException, std::exception) |