Gjs trying to call g_error_free(NULL)

I was getting some warnings from gjs because it was trying to call g_error_free() on a NULL pointer. I eventually tracked it down to using this function:

/**
 * htsp_message_to_error: (skip):
 * @msg: (transfer none):
 * Returns: (transfer full) (nullable):
 *
 * Makes a GError from a message with an error field. Returns NULL if the
 * message doesn't have an error field.
 *
 * This can't be used from gjs, because it seems to try to free the result.
 * Use htsp_message_get_error() instead.
 */
GError *htsp_message_to_error(const GstStructure *msg);

I added the (skip) and the last paragraph of the comment after discovering it was a problem.

Is this a bug in gjs, or are you not allowed to return errors this way in introspected code?

That seems correct in the API and annotations and looks like a bug in gjs. There’s probably some special casing for GError that causes this to happen. It would be best if you could create an issue about this.

OK.

https://gitlab.gnome.org/GNOME/gjs/-/issues/351

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.