diff options
author | Colin Walters <walters@verbum.org> | 2017-02-21 09:30:19 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2017-02-21 09:32:30 -0500 |
commit | 0c1603debac440978c1d55c46cb11059f8350b35 (patch) | |
tree | d84c17f3bc1c51c222baed70a710b8400bc0df31 /tests | |
parent | 2a71cb6c5bebd0874f16c18260616dec318a823a (diff) | |
download | libglnx-0c1603debac440978c1d55c46cb11059f8350b35.tar.gz |
tests/xattrs: Fix possible NULL allocation
This showed up in the ostree runs with `-fsanitize=undefined` - if we happened
to get `0` then `g_malloc` would return `NULL`. However, what's interesting is
it seemed to happen *consistently*. I think what's going on is GCC proved that
the value *could* be zero, and hence it *could* return NULL, and hence it was
undefined behavior. Hooray for `-fsanitize=undefined`.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-libglnx-xattrs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/test-libglnx-xattrs.c b/tests/test-libglnx-xattrs.c index 9a39870..21bdbdb 100644 --- a/tests/test-libglnx-xattrs.c +++ b/tests/test-libglnx-xattrs.c @@ -42,7 +42,7 @@ static gboolean set_random_xattr_value (int fd, const char *name, GError **error) { const guint8 randxattrbyte = g_random_int_range (0, 256); - const guint32 randxattrvalue_len = g_random_int () % 256; /* Picked to be not too small or large */ + const guint32 randxattrvalue_len = (g_random_int () % 256) + 1; /* Picked to be not too small or large */ g_autofree char *randxattrvalue = g_malloc (randxattrvalue_len); memset (randxattrvalue, randxattrbyte, randxattrvalue_len); |