Re: [Vimprobable-users] [PATCH] Possible fix for crash on :echo
Vimprobable is a lean web browser optimised for full keyboard control
Brought to you by:
hanness
From: Daniel C. <dan...@gm...> - 2011-09-16 23:41:49
|
Hi! On Fri, Sep 16, 2011 at 05:18:25PM +0200, Hans-Peter Deifel wrote: > Hi, > > It would be nice if we could finally get consistent behaviour regarding > mallocing and freeing. This means, that script() shouldn't free > anything and we should instead track down all the places where it's used > and call free() there. This should also remove the need for a SAVEFREE > macro. I like consistency, and the most parts use free-by-caller, so why not to apply this paradigm to the script() function too. Following patch removes freeing from script function and fixex also the crash on :echo foo call. I think the code should be refactered. In the last days i saw multiple places, where memory is allocated via g_strdup() and not free()d. By the way we could replace parts like following by g_strdup_printf(). new = g_malloc(sizeof("http://") + len); strcpy(new, "http://"); memcpy(&new[sizeof("http://") - 1], filename, len + 1); Example cames from togge_proxy function where the new pointer isn't free()d. Daniel |