1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | #include <stdlib.h>
|
|---|
| 2 | #include <pthread.h>
|
|---|
| 3 | #include <string.h>
|
|---|
| 4 |
|
|---|
| 5 | void __VERIFIER_assert(int expression) { if (!expression) { ERROR: goto ERROR; }; return; }
|
|---|
| 6 |
|
|---|
| 7 | char *v;
|
|---|
| 8 |
|
|---|
| 9 | void *thread1(void * arg)
|
|---|
| 10 | {
|
|---|
| 11 | v = malloc(sizeof(char) * 8);
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | void *thread2(void *arg)
|
|---|
| 15 | {
|
|---|
| 16 | if (v) strcpy(v, "Bigshot");
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 | int main()
|
|---|
| 21 | {
|
|---|
| 22 | pthread_t t1, t2;
|
|---|
| 23 |
|
|---|
| 24 | pthread_create(&t1, 0, thread1, 0);
|
|---|
| 25 | pthread_join(t1, 0);
|
|---|
| 26 |
|
|---|
| 27 | pthread_create(&t2, 0, thread2, 0);
|
|---|
| 28 | pthread_join(t2, 0);
|
|---|
| 29 |
|
|---|
| 30 | __VERIFIER_assert(v[0] == 'B'); // <---- wrong, malloc() can fail and therefore no strcpy!
|
|---|
| 31 |
|
|---|
| 32 | return 0;
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.