Memory leak with byte arrays
There's a memory leak that can be found while running testGIMarshalling.js
under valgrind:
==408== 56 (40 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 964 of 1,525
==408== at 0x4C2BBE0: malloc (vg_replace_malloc.c:299)
==408== by 0x5AC9485: g_malloc (gmem.c:94)
==408== by 0x5AE10DB: g_slice_alloc (gslice.c:1025)
==408== by 0x5A9E9C2: g_bytes_new_with_free_func (gbytes.c:184)
==408== by 0x5A9EA1E: g_bytes_new_take (gbytes.c:126)
==408== by 0x5A9786C: g_byte_array_free_to_bytes (garray.c:1745)
==408== by 0x6C8A0B3: ??? (byteArray.cpp:107)
==408== by 0x6C8AA9D: gjs_byte_array_get_bytes (byteArray.cpp:765)
==408== by 0x6C43800: gjs_value_to_g_argument (arg.cpp:1630)
==408== by 0x6C456A7: gjs_value_to_arg (arg.cpp:2134)
==408== by 0x6C6145C: ??? (function.cpp:977)
==408== by 0x6C6333F: ??? (function.cpp:1357)
At first glance, it looks like we special case GBytes
in arg.cpp when marshalling a JS ByteArray object into C, but we don't special case it in gjs_g_arg_release_internal()
.