Skip to content

Commit

Permalink
Merge branch 'wip/hughsie/gbytes-null' into 'main'
Browse files Browse the repository at this point in the history
glib/gbytes: Be more careful when saving a GBytes of NULL

See merge request GNOME/glib!4406
  • Loading branch information
mcatanzaro committed Nov 20, 2024
2 parents 3e87611 + 9ddc973 commit b21bc8d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion glib/gbytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ g_bytes_new (gconstpointer data,
GBytesInline *bytes;

bytes = g_malloc (sizeof *bytes + size);
bytes->bytes.data = bytes->inline_data;
bytes->bytes.data = data != NULL ? bytes->inline_data : NULL;
bytes->bytes.size = size;
bytes->bytes.free_func = NULL;
bytes->bytes.user_data = NULL;
Expand Down
1 change: 1 addition & 0 deletions glib/tests/bytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ test_null (void)
gsize size;

bytes = g_bytes_new (NULL, 0);
g_assert_null (g_bytes_get_data (bytes, NULL));

data = g_bytes_unref_to_data (bytes, &size);

Expand Down

0 comments on commit b21bc8d

Please sign in to comment.