[Gnucash-changes] Eliminate a double free of memory.

Derek Atkins warlord at MIT.EDU
Thu Jun 2 13:19:03 EDT 2005


Chris Shoemaker <c.shoemaker at cox.net> writes:

> On Thu, Jun 02, 2005 at 11:10:48AM -0400, David Hampton wrote:
>> --- src/business/business-gnome/dialog-customer.c
>> +++ src/business/business-gnome/dialog-customer.c
>> @@ -383,7 +383,8 @@
>>    CustomerWindow *cw = user_data;
>>  
>>    gtk_widget_destroy (cw->dialog);
>> -  cw->dialog = NULL;
>> +  // cw has already been freed by this point.
>> +  // cw->dialog = NULL;
>>  }
>
> This patch looks wrong.  1) This certainly doesn't fix a double-free
> bug because it doesn't remove a free.  2) gtk_widget_destroy() may
> free cw->dialog, in which case it's wise to assign NULL.
> gtk_widget_destroy should never free cw.  If it does, then something
> is seriously wrong somewhere else, but not here.

It's certainly possible that gtk_widget_destroy() indirectly causes
the cw object to get destroyed.  But you're correct, this isn't
fixing a double-free.  It might fix a SEGV or memory corruption.

-derek
-- 
       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available


More information about the gnucash-devel mailing list