tests: Fix undefined behaviour
Undefined behaviour in the test support code.
diff --git a/src/test_libFLAC/md5.c b/src/test_libFLAC/md5.c
index 88b72c0..0c52327 100644
--- a/src/test_libFLAC/md5.c
+++ b/src/test_libFLAC/md5.c
@@ -167,8 +167,7 @@
static FLAC__bool test_md5_codec(void)
{
FLAC__int32 arrays[MAX_CHANNEL_COUNT][MD5_SAMPLE_COUNT], *pointer[MAX_CHANNEL_COUNT], **signal;
- FLAC__int32 seed = 0x12345679;
- unsigned chan, byte_size;
+ unsigned chan, byte_size, seed = 0x12345679;
/* Set up signal data using a trival Linear Congruent PRNG. */
signal = &pointer[0];
diff --git a/src/test_libs_common/metadata_utils.c b/src/test_libs_common/metadata_utils.c
index cef3222..11491f8 100644
--- a/src/test_libs_common/metadata_utils.c
+++ b/src/test_libs_common/metadata_utils.c
@@ -338,7 +338,7 @@
printf("FAILED, data_length mismatch, expected %u, got %u\n", block->data_length, blockcopy->data_length);
return false;
}
- if(memcmp(blockcopy->data, block->data, block->data_length)) {
+ if(block->data_length > 0 && memcmp(blockcopy->data, block->data, block->data_length)) {
printf("FAILED, data mismatch\n");
return false;
}