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.
This commit is contained in:
herman ten brugge
2025-08-05 22:14:13 +02:00
parent 311218ee5f
commit 9dffcd29d3

View File

@@ -204,14 +204,15 @@ int test15(void)
int test16() int test16()
{ {
char *demo = "This is only a test."; char *demo = "This is only a test.";
char *p; char *p, *q;
p = alloca(16); p = alloca(16);
strcpy(p,"12345678901234"); strcpy(p,"12345678901234");
/* Test alloca embedded in a larger expression */ /* Test alloca embedded in a larger expression */
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)+1),demo) ); printf("alloca : %s : %s\n", p, strcpy(q=alloca(strlen(demo)+1),demo) );
allocf(p); allocf(p);
allocf(q);
return 0; return 0;
} }
@@ -220,14 +221,15 @@ int test16()
int test17() int test17()
{ {
char *demo = "This is only a test."; char *demo = "This is only a test.";
char *p; char *p, *q;
p = alloca(16); p = alloca(16);
strcpy(p,"12345678901234"); strcpy(p,"12345678901234");
/* Test alloca embedded in a larger expression */ /* Test alloca embedded in a larger expression */
printf("alloca : %s : %s\n", p, strcpy(alloca(strlen(demo)),demo) ); printf("alloca : %s : %s\n", p, strcpy(q=alloca(strlen(demo)),demo) );
allocf(p); allocf(p);
allocf(q);
return 0; return 0;
} }