tests: Avoid calling malloc(0) in gvariant tests

Its behaviour is implementation-defined according to POSIX
(https://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html),
and we’d quite like it to consistently return `NULL` for a zero-size
allocation.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2024-01-16 16:55:08 +00:00
parent 635f8d43eb
commit 1e0cec289c

View File

@ -1352,7 +1352,7 @@ align_malloc (gsize size)
* have malloc() that returns non-8-aligned. if so, we need to try
* harder here.
*/
mem = malloc (size);
mem = (size > 0) ? malloc (size) : NULL;
#endif
return mem;