As was pointed out on tinycc-devel, many uses of get_tok_str gives as second parameter the value NULL. However, that pointer was unconditionally dereferenced in get_tok_ptr. This commit explicitely add support for thas case.
Unified · Split
| @@ -255,9 +255,15 @@ ST_FUNC char *get_tok_str(int v, CValue *cv) · 254 unmodified lines | ||
| 255 | 255 | static char buf[STRING_MAX_SIZE + 1]; |
| 256 | 256 | static CString cstr_buf; |
| 257 | 257 | CString *cstr; |
| 258 | + CValue cval; | |
| 258 | 259 | char *p; |
| 259 | 260 | int i, len; |
| 260 | 261 | |
| 262 | + if (!cv) { | |
| 263 | + cval.ull = 0; | |
| 264 | + cv = &cval; | |
| 265 | + } | |
| 266 | + | |
| 261 | 267 | /* NOTE: to go faster, we give a fixed buffer for small strings */ |
| 262 | 268 | cstr_reset(&cstr_buf); |
| 263 | 269 | cstr_buf.data = buf; |