Bug 40541

Summary: Two memory leaks
Product: WebKit Reporter: genhua.liu <genhua.liu>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: mrobinson
Priority: P1    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   

genhua.liu
Reported 2010-06-13 00:26:36 PDT
The following two file has memory leaks: File: webkitwebview.cpp // Internal subresource management void webkit_web_view_add_resource(WebKitWebView* webView, char* identifier, WebKitWebResource* webResource) { WebKitWebViewPrivate* priv = webView->priv; if (!priv->mainResource) { priv->mainResource = webResource; priv->mainResourceIdentifier = g_strdup(identifier); return; } g_hash_table_insert(priv->subResources, identifier, webResource); } should be fixed as: priv->mainResourceIdentifier = identifier; File: FileSystemGtk.cpp Vector<String> listDirectory(const String& path, const String& filter) { Vector<String> entries; gchar* filename = filenameFromString(path); GDir* dir = g_dir_open(filename, 0, 0); if (!dir) return entries; GPatternSpec *pspec = g_pattern_spec_new((filter.utf8()).data()); while (const char* name = g_dir_read_name(dir)) { if (!g_pattern_match_string(pspec, name)) continue; gchar* entry = g_build_filename(filename, name, NULL); entries.append(filenameToString(entry)); g_free(entry); } g_dir_close(dir); g_free(filename); return entries; } should be fixed as: 1. if (!dir) { g_free(filename); return entries; } 2. g_dir_close(dir); //add pspec free here g_pattern_spec_free(pspec); g_free(filename);
Attachments
Martin Robinson
Comment 1 2010-08-20 19:46:04 PDT
> should be fixed as: > priv->mainResourceIdentifier = identifier; This seems unsafe, because the char array may be temporary. It seems that this private member is freed at the appropriate times though. Perhaps this has been fixed since you filed this? > File: FileSystemGtk.cpp > Vector<String> listDirectory(const String& path, const String& filter) This case seems to be fixed now. Thanks for reporting, but it seems that these issues have been fixed. Feel free to re-open if this is not the case.
Note You need to log in before you can comment on or make changes to this bug.