About Revert "Check pointer before deferenging"

Matteo Casalin matteo.casalin at yahoo.com
Mon Jun 10 08:19:51 PDT 2013

>On 06/09/2013 08:32 AM, Matteo Casalin wrote:

>> Hi Caolán,
>>      first of all thanks for the rationale in your revert (commit
>> 8a3f61c42b7dfd7221bd7bc9d9a5a70c052a0bf5), I understand it is not
>> mandatory but it really helps.
>> I introduced those checks while visually scrolling through code for a
>> previous commit. Is there a rule of thumb on whether these checks are
>> required or not (and where), or should I just rely on reports from code
>> analysis tools?
>First of all, introducing null pointer checks without understanding the 
>code is never a good idea.  If you do not understand the code in 
>question, you neither know (a) whether the pointer is intended not to be 
>null here and can only be so due to a programming error somewhere else 
>(so the fix should also go somewhere else), nor (b) what to do in the 
>else branch.
>And in the special case of a pointer obtained from plain new, it can 
>never be null anyway, as already explained by Caolán.

Looking back to the code, I completely misunderstood the aim of the same check after one of the two that I introduced.
Thanks for the clarification.


>LibreOffice mailing list
>LibreOffice at lists.freedesktop.org

More information about the LibreOffice mailing list