deal with usign g_free for NULL

This commit is contained in:
Dan Jenkins
2023-03-20 21:36:27 +00:00
parent 769c8857a5
commit f9daac4459

View File

@@ -36,7 +36,8 @@ func (o *Object) GObject() *glib.Object { return o.InitiallyUnowned.Object }
// GetName returns the name of this object. // GetName returns the name of this object.
func (o *Object) GetName() string { func (o *Object) GetName() string {
cName := C.gst_object_get_name((*C.GstObject)(o.Instance())) cName := C.gst_object_get_name((*C.GstObject)(o.Instance()))
defer C.free(unsafe.Pointer(cName)) //cName could be NULL which needs to be freed using
defer C.g_free(unsafe.Pointer(cName))
return C.GoString(cName) return C.GoString(cName)
} }