Hello all,
I’m a beginner with GLib. I’m using 2.80 on Ubuntu Noble. I’m encountering a crash. Before filling a bug, I want to know if something is wrong with my code:
#include <stdio.h>
#include <glib.h>
#include <glib-object.h>
gboolean is_valid_uri(char const * uri_str)
{
GError * error = NULL;
GUri * const parsed_uri = g_uri_parse(uri_str, G_URI_FLAGS_NONE, &error);
if (parsed_uri == NULL)
{
g_error_free(error);
return FALSE;
}
g_object_unref(parsed_uri); // <-- CRASH IS HERE
return TRUE;
}
int main(int ac, char ** av)
{
printf("%d", is_valid_uri("https://gitlab.gnome.org"));
return 0;
}
Am I right to believe that instances of GUri should be unrefed after use?
If so, is there anything else wrong with my code?
EDIT: Crash is actually a segfault.