Closed Bug 273337 Opened 20 years ago Closed 20 years ago

memory from gtk widgets should be allocated using gmalloc

Categories

(Core Graveyard :: Embedding: GTK Widget, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: toddf, Assigned: toddf)

Details

Attachments

(1 file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; chrome://navigator/locale/navigator.properties; rv:1.7.5) Gecko/20041107 Firefox/1.0 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; chrome://navigator/locale/navigator.properties; rv:1.7.5) Gecko/20041107 Firefox/1.0 many functions in gtkmozembed return memory that is allocated with the standard c functions. This is ok but could be a serious problem if a programmer decided to use alternate gmalloc functions and then accidentally called g_free on the memory returned from a gtkmozembed function. Reproducible: Always Steps to Reproduce:
As far as I know, it's ok to free memory allocated by strdup and malloc using g_free
I do not believe that is the case. A user can use the following api to override g_malloc and g_free. If i'm not mistaken this function does not override malloc and free, making it unsafe to mix the two. see: from http://developer.gnome.org/doc/API/2.0/glib/glib-Memory-Allocation.html void g_mem_set_vtable (GMemVTable *vtable); gboolean g_mem_is_system_malloc (void); also, looking at glibs memory function implementation g_malloc for instance: uses the function defined in vtable so unless that function is compatible with the standard libraries free then it is absolutely not safe.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #167994 - Flags: superreview?(bryner)
Attachment #167994 - Flags: review?(bryner)
Comment on attachment 167994 [details] [diff] [review] Replaces strdup calls with g_strdup good to know... we're probably violating this in other places as well.
Attachment #167994 - Flags: superreview?(bryner)
Attachment #167994 - Flags: superreview+
Attachment #167994 - Flags: review?(bryner)
Attachment #167994 - Flags: review+
Assignee: blizzard → toddf
Fix checked in for 1.8b. Todd, in general you want to request review for your patches (see http://www.mozilla.org/hacking/life-cycle.html and http://www.mozilla.org/owners.html) and when they have reviews it's a good idea to ping someone to check them in. Keeps them from getting lost. ;)
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
This is the same as an API change. I would have rathered that this not have been checked in.
Chris, it's your module, so it's your call. If we clearly document that the return values of certain functions must be deallocated with a certain allocator, then we can revert this patch, of course...
I've looked at epiphany, galeon, yelp and devhelp (all gecko embedders I could find in GNOME), and all assume that you can free the return values with g_free. That suggests that this is a widespread assumption.
It's a mistake, sure. But fixing it at this point means that everyone has to update their clients. The cost/benefit ratio here seems low to me.
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: