File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed
Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change 55
66#include <stddef.h>
77#include <stdio.h>
8+ #include <stdlib.h>
89#include <string.h>
910#include "notrandombytes/notrandombytes.h"
1011
@@ -103,20 +104,35 @@ static int test_mld_polyz_unpack_core(const uint8_t *input,
103104
104105static 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 ;
109+ int rc = 0 ;
108110
109- memset (test_bytes , 0 , MLDSA_POLYZ_PACKEDBYTES );
110- CHECK (test_mld_polyz_unpack_core (test_bytes , "polyz_unpack_zeros" ) == 0 );
111+ if (test_bytes == NULL )
112+ {
113+ return 1 ;
114+ }
111115
116+ memset (test_bytes , 0 , MLDSA_POLYZ_PACKEDBYTES );
117+ if (test_mld_polyz_unpack_core (test_bytes , "polyz_unpack_zeros" ) != 0 )
118+ {
119+ rc = 1 ;
120+ goto cleanup ;
121+ }
112122
113123 for (i = 0 ; i < NUM_RANDOM_TESTS ; i ++ )
114124 {
115125 randombytes (test_bytes , MLDSA_POLYZ_PACKEDBYTES );
116- CHECK (test_mld_polyz_unpack_core (test_bytes , "polyz_unpack_random" ) == 0 );
126+ if (test_mld_polyz_unpack_core (test_bytes , "polyz_unpack_random" ) != 0 )
127+ {
128+ rc = 1 ;
129+ goto cleanup ;
130+ }
117131 }
118132
119- return 0 ;
133+ cleanup :
134+ free (test_bytes );
135+ return rc ;
120136}
121137#endif /* MLD_USE_NATIVE_POLYZ_UNPACK_17 || MLD_USE_NATIVE_POLYZ_UNPACK_19 */
122138
You can’t perform that action at this time.
0 commit comments