Bug 40541
| Summary: | Two memory leaks | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | genhua.liu <genhua.liu> |
| Component: | WebKitGTK | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | mrobinson |
| Priority: | P1 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | PC | ||
| OS: | Linux | ||
genhua.liu
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Martin Robinson
> 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.