protect some more accesses to global data with the semaphore. (And for the testcase: don't just write into global data, use local copies; it's not important for speed here).
Unified · Split
| @@ -749,7 +749,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 748 unmodified lines | |||
| 749 | s = tcc_mallocz(sizeof(TCCState)); | 749 | s = tcc_mallocz(sizeof(TCCState)); |
| 750 | if (!s) | 750 | if (!s) |
| 751 | return NULL; | 751 | return NULL; |
| 752 | WAIT_SEM(); | ||
| 752 | ++nb_states; | 753 | ++nb_states; |
| 754 | POST_SEM(); | ||
| 753 | 755 | ||
| 754 | #undef gnu_ext | 756 | #undef gnu_ext |
| 755 | 757 | ||
| @@ -958,8 +960,10 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 202 unmodified lines | |||
| 958 | #endif | 960 | #endif |
| 959 | 961 | ||
| 960 | tcc_free(s1); | 962 | tcc_free(s1); |
| 963 | WAIT_SEM(); | ||
| 961 | if (0 == --nb_states) | 964 | if (0 == --nb_states) |
| 962 | tcc_memcheck(); | 965 | tcc_memcheck(); |
| 966 | POST_SEM(); | ||
| 963 | } | 967 | } |
| 964 | 968 | ||
| 965 | LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) | 969 | LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) |
| @@ -105,13 +105,15 @@ void parse_args(TCCState *s) · 104 unmodified lines | |||
| 105 | else if (a[1] == 'L') | 105 | else if (a[1] == 'L') |
| 106 | tcc_add_library_path(s, a+2); | 106 | tcc_add_library_path(s, a+2); |
| 107 | else if (a[1] == 'D') { | 107 | else if (a[1] == 'D') { |
| 108 | char *eq = strchr(a+2, '='); | 108 | char *dup = strdup(a); |
| 109 | char *eq = strchr(dup+2, '='); | ||
| 109 | if (eq) { | 110 | if (eq) { |
| 110 | *eq = 0; | 111 | *eq = 0; |
| 111 | tcc_define_symbol(s, a+2, eq+1); | 112 | tcc_define_symbol(s, dup+2, eq+1); |
| 112 | *eq = '='; | 113 | *eq = '='; |
| 113 | } else | 114 | } else |
| 114 | tcc_define_symbol(s, a+2, NULL); | 115 | tcc_define_symbol(s, dup+2, NULL); |
| 116 | free(dup); | ||
| 115 | } | 117 | } |
| 116 | } | 118 | } |
| 117 | } | 119 | } |