Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-10-17 16:02:52 +0000
committerEric Williams2018-10-17 19:17:25 +0000
commitf6d885c6a58eb6a15ebd722d25f92cc478c572ca (patch)
tree52886fe331f288acda93f580d4f930774abe3556
parent089dc108768d13932676efae9572e5e35fbdf445 (diff)
downloadeclipse.platform.swt-f6d885c6a58eb6a15ebd722d25f92cc478c572ca.tar.gz
eclipse.platform.swt-f6d885c6a58eb6a15ebd722d25f92cc478c572ca.tar.xz
eclipse.platform.swt-f6d885c6a58eb6a15ebd722d25f92cc478c572ca.zip
Bug 540200: [Webkit2] BrowserFunction strings are truncated after
reloading the page Perform a deep copy of strings received from GDBus, as these might be freed later on and can lead to issues. Tested with JBoss Tools/Red Hat Devstudio using the Red Hat Central page. The snippets/tests from bug 536141 still work as expected, and AllBrowserTests pass. Change-Id: I03e1aa092e0dec2965d749eeae27074c0951ee16 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c
index fd958309a8..e7d122c17a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/library/webkitgtk_extension.c
@@ -36,8 +36,8 @@ static const gchar interface[] = "org.eclipse.swt.gdbusInterface";
typedef struct {
guint64 page_id;
- const gchar *function;
- const gchar *url;
+ gchar *function;
+ gchar *url;
} BrowserFunction;
GSList *function_list = NULL;
@@ -312,7 +312,7 @@ static WebKitFrame *webkitgtk_extension_get_main_frame (const guint64 id) {
/*
* Execute the Javascript for the given page and URL.
*/
-static gboolean webkitgtk_extension_execute_script (const guint64 page_id, const gchar* script, const gchar* url) {
+static gboolean webkitgtk_extension_execute_script (const guint64 page_id, gchar* script, gchar* url) {
WebKitFrame *main_frame = webkitgtk_extension_get_main_frame (page_id);
JSStringRef url_string = JSStringCreateWithUTF8CString (url);
@@ -359,20 +359,25 @@ gint find_browser_function (gconstpointer item, gconstpointer target) {
void add_browser_function(guint64 page_id, const gchar *function, const gchar *url) {
BrowserFunction *func = g_slice_new0(BrowserFunction);
func->page_id = page_id;
- func->function = function;
- func->url = url;
+ func->function = g_strdup(function);
+ func->url = g_strdup(url);
function_list = g_slist_append(function_list, func);
}
void remove_browser_function(guint64 page_id, const gchar *function, const gchar *url) {
BrowserFunction *func = g_slice_new0(BrowserFunction);
func->page_id = page_id;
- func->function = function;
- func->url = url;
+ func->function = g_strdup(function);
+ func->url = g_strdup(url);
GSList *to_remove = g_slist_find_custom(function_list, func, find_browser_function);
if (to_remove != NULL) {
+ BrowserFunction *delete_func = to_remove->data;
+ g_free(delete_func->function);
+ g_free(delete_func->url);
function_list = g_slist_delete_link(function_list, to_remove);
}
+ g_free(func->function);
+ g_free(func->url);
g_slice_free(BrowserFunction, func);
}

Back to the top