Bug 21827 - Memory leak in webkit_web_view_load_string
Summary: Memory leak in webkit_web_view_load_string
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-23 03:12 PDT by Michael Tross
Modified: 2008-10-27 14:46 PDT (History)
1 user (show)

See Also:


Attachments
Patch to fix memory leak in webkit_web_view_load_string() (740 bytes, patch)
2008-10-23 03:13 PDT, Michael Tross
no flags Details | Formatted Diff | Diff
Patch to fix memory leak in webkit_web_view_load_string() (1.35 KB, patch)
2008-10-24 04:44 PDT, Michael Tross
alp: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Tross 2008-10-23 03:12:36 PDT
The Gtk method webkit_web_view_load_string() takes a string as gchar* argument to set the page content. This string is passed down to a SharedBuffer, but duplicated before with strdup(), this memory is lost (verified with valgrind).

void webkit_web_view_load_string(WebKitWebView* webView, const gchar* content, const gchar* contentMimeType, const gchar* contentEncoding, const 
{
    ....

    RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(strdup(content), strlen(content));
    SubstituteData substituteData(sharedBuffer.release(), contentMimeType ? String(contentMimeType) : "text/html", contentEncoding ? String(conte

    ....
}
Comment 1 Michael Tross 2008-10-23 03:13:42 PDT
Created attachment 24595 [details]
Patch to fix memory leak in webkit_web_view_load_string()
Comment 2 Mark Rowe (bdash) 2008-10-23 13:34:58 PDT
This looks fine, but the patch needs a ChangeLog entry.  Can you please add one, and upload the new patch?  Be sure to set the "review" flag on the attachment to "?" when you upload the patch to indicate that you'd like it reviewed!
Comment 3 Michael Tross 2008-10-24 04:44:01 PDT
Created attachment 24638 [details]
Patch to fix memory leak in webkit_web_view_load_string()

added ChangeLog entry and requested review
Comment 4 Alp Toker 2008-10-24 09:28:28 PDT
Comment on attachment 24638 [details]
Patch to fix memory leak in webkit_web_view_load_string()

r=me
Comment 5 Jan Alonzo 2008-10-27 14:46:33 PDT
Landed in r37903. Cheers.