Skip to content

Commit 210dfa9

Browse files
committed
[GTK] Fix memory leak, GUri was not freed.
Don't call soup_uri_free on libsoup3, use g_uri_unref instead. soup_uri_free was removed in libsoup3.
1 parent b43e86c commit 210dfa9

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12907,6 +12907,24 @@ JNIEXPORT jlong JNICALL OS_NATIVE(g_1uri_1parse)
1290712907
}
1290812908
#endif
1290912909

12910+
#ifndef NO_g_1uri_1unref
12911+
JNIEXPORT void JNICALL OS_NATIVE(g_1uri_1unref)
12912+
(JNIEnv *env, jclass that, jlong arg0)
12913+
{
12914+
OS_NATIVE_ENTER(env, that, g_1uri_1unref_FUNC);
12915+
/*
12916+
g_uri_unref(arg0);
12917+
*/
12918+
{
12919+
OS_LOAD_FUNCTION(fp, g_uri_unref)
12920+
if (fp) {
12921+
((void (CALLING_CONVENTION*)(jlong))fp)(arg0);
12922+
}
12923+
}
12924+
OS_NATIVE_EXIT(env, that, g_1uri_1unref_FUNC);
12925+
}
12926+
#endif
12927+
1291012928
#ifndef NO_g_1utf16_1offset_1to_1pointer
1291112929
JNIEXPORT jlong JNICALL OS_NATIVE(g_1utf16_1offset_1to_1pointer)
1291212930
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#define FcConfigAppFontAddFile_LIB LIB_FONTCONFIG
6161
#define pango_attr_insert_hyphens_new_LIB LIB_PANGO
6262
#define g_uri_parse_LIB LIB_GLIB
63+
#define g_uri_unref_LIB LIB_GLIB
6364

6465
/* Field accessors */
6566
#define G_OBJECT_CLASS_CONSTRUCTOR(arg0) (arg0)->constructor

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,7 @@ typedef enum {
10381038
g_1type_1register_1static_FUNC,
10391039
g_1unsetenv_FUNC,
10401040
g_1uri_1parse_FUNC,
1041+
g_1uri_1unref_FUNC,
10411042
g_1utf16_1offset_1to_1pointer_FUNC,
10421043
g_1utf16_1offset_1to_1utf8_1offset_FUNC,
10431044
g_1utf16_1pointer_1to_1offset_FUNC,

bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,10 @@ public static boolean isX11 () {
15521552
* @param error cast=(GError **)
15531553
*/
15541554
public static final native long g_uri_parse (byte[] uri_string, long flags, long[] error);
1555+
/**
1556+
* @method flags=dynamic
1557+
*/
1558+
public static final native void g_uri_unref (long uri);
15551559
/** @method flags=const */
15561560
public static final native int glib_major_version();
15571561
/** @method flags=const */

bundles/org.eclipse.swt/Eclipse SWT WebKit/gtk/org/eclipse/swt/browser/WebKit.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,11 @@ static boolean setCookie(String cookieUrl, String cookieValue) {
12421242
setCookie_callback.getAddress(), callbackID);
12431243
Webkit2AsyncReturnObj retObj = execAsyncAndWaitForReturn(cookieBrowser, asyncFunc, " setCookie() was called");
12441244

1245-
WebKitGTK.soup_uri_free (uri);
1245+
if (WebKitGTK.soup_get_major_version()==2) {
1246+
WebKitGTK.soup_uri_free (uri);
1247+
} else {
1248+
OS.g_uri_unref(uri);
1249+
}
12461250

12471251
if (retObj.swtAsyncTimeout) {
12481252
return false;

0 commit comments

Comments
 (0)