[Libreoffice] [PATCH] cppcheck warning in sw/source/ui/uiview/viewprt.cxx

Noel Power nopower at novell.com
Mon Oct 4 07:13:15 PDT 2010

Hi Harri, thanks for the patch, committed
On Sat, 2010-10-02 at 09:40 +0300, Harri Pitkänen wrote:
> Hi!
> Here goes my first patch. It silences a "possible null pointer dereference" of
> pPage (at the end of diff). Perhaps not for merging yet since my build has not
> yet progressed far enough to see that it builds and works and I'd also like to
> know what is the preferred way of handling warnings like this.
> The issue here is that both pFact and fnCreatePage are checked for nullness
> but if either of them is null then pPage would get dereferenced as null. So we
> will crash here anyway if that is the case, the question is what is the best
> way to handle it? With my patch the null pointer crash will happen at the
> earliest possible location, but should I add ASSERT(pFact) and
> ASSERT(fnCreatePage) to document that this is intentional?
I have to admit the state ( or recommended usage ) of the various
ASSERTish macros lying around the code is a bit of a mystery to me.
Getting of cppcheck noise in this case is a win imo, I pushed your orig

then I got paranoid, coded to avoid the core ( leaving it up to the
caller to check the page ) and put in ( hopefully ) the correct and
current ASSERT-like macro

thanks again and looking forward to more patches, from you



More information about the LibreOffice mailing list