From b61e65139015ff1340b4fac0d290e424d276218c Mon Sep 17 00:00:00 2001 From: Mikhail Denisenko Date: Sat, 30 Dec 2023 12:00:16 -0500 Subject: [PATCH] Fix read after free bug --- src/org/freedesktop/gstreamer/Gst.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/freedesktop/gstreamer/Gst.java b/src/org/freedesktop/gstreamer/Gst.java index 1621fbbd..14d8f163 100644 --- a/src/org/freedesktop/gstreamer/Gst.java +++ b/src/org/freedesktop/gstreamer/Gst.java @@ -358,7 +358,8 @@ private static GError extractError(Pointer errorPtr) { GErrorStruct struct = new GErrorStruct(errorPtr); struct.read(); GError err = new GError(struct.getCode(), struct.getMessage()); - GLIB_API.g_error_free(struct); + // freeing via raw pointer to prevent JNA from reading contents of the freed structure + GLIB_API.g_error_free(errorPtr); return err; }