Skip to content

Commit

Permalink
tests/7 gnome: Fix incorrect unref of GResource
Browse files Browse the repository at this point in the history
The returned GResource is transfer-none, since the generated function
basically calls g_static_resource_get_resource(). It should not be
unreffed. Causes an abort on Debian:

GLib-GIO:ERROR:../../../gio/gresource.c:1451:g_static_resource_fini: assertion failed: (g_atomic_int_get (&resource->ref_count) >= 2)
  • Loading branch information
nirbheek committed Sep 3, 2022
1 parent 1bc9f37 commit 7d0bb45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions test cases/frameworks/7 gnome/resources/generated-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define EXPECTED "This is a generated resource.\n"

int main(int argc, char **argv) {
GResource *res = generated_resources_get_resource();
generated_resources_get_resource();
GError *err = NULL;
GBytes *data = g_resources_lookup_data("/com/example/myprog/res3.txt",
G_RESOURCE_LOOKUP_FLAGS_NONE, &err);
Expand All @@ -22,6 +22,5 @@ int main(int argc, char **argv) {
}
fprintf(stdout, "All ok.\n");
g_bytes_unref(data);
g_resource_unref(res);
return 0;
}
4 changes: 2 additions & 2 deletions test cases/frameworks/7 gnome/resources/simple-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#define EXPECTED "This is a resource.\n"

int main(int argc, char **argv) {
GResource *res = simple_resources_get_resource();
simple_resources_get_resource();

GError *err = NULL;
GBytes *data = g_resources_lookup_data("/com/example/myprog/res1.txt",
G_RESOURCE_LOOKUP_FLAGS_NONE, &err);
Expand All @@ -22,6 +23,5 @@ int main(int argc, char **argv) {
}
fprintf(stdout, "All ok.\n");
g_bytes_unref(data);
g_resource_unref(res);
return 0;
}

0 comments on commit 7d0bb45

Please sign in to comment.