Skip to content

Commit 3cf65ad

Browse files
committed
switch polyz_unpack unit test to malloc
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
1 parent 881027e commit 3cf65ad

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

test/test_unit.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <stddef.h>
77
#include <stdio.h>
8+
#include <stdlib.h>
89
#include <string.h>
910
#include "notrandombytes/notrandombytes.h"
1011

@@ -103,19 +104,24 @@ static int test_mld_polyz_unpack_core(const uint8_t *input,
103104

104105
static int test_native_polyz_unpack(void)
105106
{
106-
uint8_t test_bytes[MLDSA_POLYZ_PACKEDBYTES];
107+
uint8_t *test_bytes = malloc(MLDSA_POLYZ_PACKEDBYTES);
107108
int i;
108109

110+
if (test_bytes == NULL)
111+
{
112+
return 1;
113+
}
114+
109115
memset(test_bytes, 0, MLDSA_POLYZ_PACKEDBYTES);
110116
CHECK(test_mld_polyz_unpack_core(test_bytes, "polyz_unpack_zeros") == 0);
111117

112-
113118
for (i = 0; i < NUM_RANDOM_TESTS; i++)
114119
{
115120
randombytes(test_bytes, MLDSA_POLYZ_PACKEDBYTES);
116121
CHECK(test_mld_polyz_unpack_core(test_bytes, "polyz_unpack_random") == 0);
117122
}
118123

124+
free(test_bytes);
119125
return 0;
120126
}
121127
#endif /* MLD_USE_NATIVE_POLYZ_UNPACK_17 || MLD_USE_NATIVE_POLYZ_UNPACK_19 */

0 commit comments

Comments
 (0)