From: Loup Vaillant Date: Sun, 28 Jan 2018 23:36:24 +0000 (+0100) Subject: Fixed small undefined behaviour in tests X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=7b4145adb20fa43307b0eb9f5bca397a2d916e63;p=Monocypher.git Fixed small undefined behaviour in tests Apparently we cannot memcmp() null pointers, even when the size is zero. --- 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++;