From 2208901b270033122793e77a90561c7238dd077c Mon Sep 17 00:00:00 2001 From: Chris Bainbridge Date: Mon, 28 Oct 2024 09:45:02 +0000 Subject: [PATCH] webrtc: fix nil deref marshal *SessionDescription When the SessionDescription pointer is nil, ToGValue() will crash dereferencing the pointer. Fix this by avoiding the dereference. The ability to marshal a NULL value is required for compatibility with other languages. This change has been tested with the custom signalling from gst-plugins-rs, in which a signaller may emit a `session-requested` signal with an optional offer SDP. --- gst/gstwebrtc/session_description.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gst/gstwebrtc/session_description.go b/gst/gstwebrtc/session_description.go index 7c95966..5acfc54 100644 --- a/gst/gstwebrtc/session_description.go +++ b/gst/gstwebrtc/session_description.go @@ -104,7 +104,11 @@ func (sd *SessionDescription) ToGValue() (*glib.Value, error) { if err != nil { return nil, err } - val.SetBoxed(unsafe.Pointer(sd.ptr)) + var ptr *C.GstWebRTCSessionDescription + if sd != nil { + ptr = sd.ptr + } + val.SetBoxed(unsafe.Pointer(ptr)) return val, nil }