-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add regression test for missing init() in realloc()
- Loading branch information
1 parent
9cb4e6d
commit cba438b
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <pthread.h> | ||
#include <stdlib.h> | ||
|
||
static void *thread_func(void *arg) { | ||
arg = realloc(arg, 1024); | ||
if (!arg) { | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
free(arg); | ||
|
||
return NULL; | ||
} | ||
|
||
int main(void) { | ||
void *mem = realloc(NULL, 12); | ||
if (!mem) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
pthread_t thread; | ||
int r = pthread_create(&thread, NULL, thread_func, mem); | ||
if (r != 0) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
r = pthread_join(thread, NULL); | ||
if (r != 0) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters