Skip to content

Commit 9dffcd2

Browse files
committed
Fix tests/boundtest.c
The test leaks memory on arm/arm64/riscv because alloca is replaced by malloc and the memory is not freed for test16 and test17.
1 parent 311218e commit 9dffcd2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

tests/boundtest.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,15 @@ int test15(void)
204204
int test16()
205205
{
206206
char *demo = "This is only a test.";
207-
char *p;
207+
char *p, *q;
208208

209209
p = alloca(16);
210210
strcpy(p,"12345678901234");
211211

212212
/* Test alloca embedded in a larger expression */
213-
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)+1),demo) );
213+
printf("alloca : %s : %s\n", p, strcpy(q=alloca(strlen(demo)+1),demo) );
214214
allocf(p);
215+
allocf(q);
215216

216217
return 0;
217218
}
@@ -220,14 +221,15 @@ int test16()
220221
int test17()
221222
{
222223
char *demo = "This is only a test.";
223-
char *p;
224+
char *p, *q;
224225

225226
p = alloca(16);
226227
strcpy(p,"12345678901234");
227228

228229
/* Test alloca embedded in a larger expression */
229-
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)),demo) );
230+
printf("alloca : %s : %s\n", p, strcpy(q=alloca(strlen(demo)),demo) );
230231
allocf(p);
232+
allocf(q);
231233

232234
return 0;
233235
}

0 commit comments

Comments
 (0)