History

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.

herman ten brugge committed 1 year ago

Commit 9dffcd21 parent 311218e1 file · +6 −4Browse files

Unified · Split

tests/boundtest.c+6−4
@@ -204,14 +204,15 @@ int test15(void) · 203 unmodified lines
204int test16()204int test16()
205{205{
206 char *demo = "This is only a test.";206 char *demo = "This is only a test.";
207 char *p;207 char *p, *q;
208 208
209 p = alloca(16);209 p = alloca(16);
210 strcpy(p,"12345678901234");210 strcpy(p,"12345678901234");
211 211
212 /* Test alloca embedded in a larger expression */212 /* 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) );
214 allocf(p);214 allocf(p);
215 allocf(q);
215 216
216 return 0;217 return 0;
217}218}
@@ -220,14 +221,15 @@ int test16() · 2 unmodified lines
220int test17()221int test17()
221{222{
222 char *demo = "This is only a test.";223 char *demo = "This is only a test.";
223 char *p;224 char *p, *q;
224 225
225 p = alloca(16);226 p = alloca(16);
226 strcpy(p,"12345678901234");227 strcpy(p,"12345678901234");
227 228
228 /* Test alloca embedded in a larger expression */229 /* 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) );
230 allocf(p);231 allocf(p);
232 allocf(q);
231 233
232 return 0;234 return 0;
233}235}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t