Make get_tok_str support NULL as second param.

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.
This commit is contained in:
Thomas Preud'homme 2014-03-27 22:59:05 +08:00
parent 5c233f2cf3
commit 9a6ee577f6

View File

@ -255,9 +255,15 @@ ST_FUNC char *get_tok_str(int v, CValue *cv)
static char buf[STRING_MAX_SIZE + 1];
static CString cstr_buf;
CString *cstr;
CValue cval;
char *p;
int i, len;
if (!cv) {
cval.ull = 0;
cv = &cval;
}
/* NOTE: to go faster, we give a fixed buffer for small strings */
cstr_reset(&cstr_buf);
cstr_buf.data = buf;