[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Fix for kfilewidget.cpp
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2008-10-17 22:22:45
Message-ID: 20081017222245.GA20003 () morpheus ! apaku ! dnsalias ! org
[Download RAW message or body]

On 17.10.08 14:49:39, David Boosalis wrote:
> I agree with you that null pointers should never happen, but it did, they
> do, and they always will as long as you are writing new code.  So why not
> prevent seg faults from occurring by doing simple checks where ever

I think you're still missing what we try to explain. The code in showEvent
uses 2 pointers. One is the member variable "d" of the class KFileWidget.
This pointer is initialized inside the KFileWidget constructor, so it can
technically never be null, unless the destructor is called - at which point
the widget is destroyed and showEvent cannot be called anymore.

The other pointer that you "protected" is d->ops, where basically the same
stuff applies. It is created in KFileWidget's constructor and deleted when
deleting the KFileWidget instance.

So as you can hopefully understand, there's technically no way these two
pointers can possibly point to 0. The only possiblity that theoretically
could exist is that either of the two points to bogus data, but that would
mean someone corrupted the data that the KFileWidget instance occupies, as
inside KFileWidget there are no assignments to either of these two.

Thats why we're saying it doesn't make any sense to check for the validity
of the pointers, because if they are indeed invalid (pointing to null or
bogus data) then there's something seriously wrong somewhere else in the
code.

> practical, and this is surely a practical case as the code in question is
> seldom called

In this case the checks would just cover a different, probably
harder-to-debug problem. That is always bad, covering bugs with workarounds
in un-related code is not good.

Did you already send mail out to the koffice developers and try to debug
this with them?

Andreas

-- 
You dialed 5483.
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic