From 7b4145adb20fa43307b0eb9f5bca397a2d916e63 Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Mon, 29 Jan 2018 00:36:24 +0100 Subject: [PATCH] Fixed small undefined behaviour in tests Apparently we cannot memcmp() null pointers, even when the size is zero. --- tests/test.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test.c b/tests/test.c index c140109..9830591 100644 --- a/tests/test.c +++ b/tests/test.c @@ -64,7 +64,9 @@ static int test(void (*f)(const vector[], vector*), expected.buf = vectors[idx+nb_inputs]; expected.size = sizes [idx+nb_inputs]; status |= out.size - expected.size; - status |= memcmp(out.buf, expected.buf, out.size); + if (out.size != 0) { + status |= memcmp(out.buf, expected.buf, out.size); + } free(out.buf); idx += nb_inputs + 1; nb_tests++; -- 2.47.3