[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
change
http://cgit.freedesktop.org/libreoffice/writer/commit/?id=8b072fd99db5f6ca0f0b3adf9acfebddd3c47854

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
http://cgit.freedesktop.org/libreoffice/writer/commit/?id=a2486209b950544c8db3650521d0c9689744f3b8

thanks again and looking forward to more patches, from you

Noel


 




More information about the LibreOffice mailing list