From 9a6ee577f6165dccfde424732bfc6f16f1e2811b Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Thu, 27 Mar 2014 22:59:05 +0800 Subject: [PATCH] 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. --- tccpp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tccpp.c b/tccpp.c index 2609ad7d..f4b7b1a1 100644 --- a/tccpp.c +++ b/tccpp.c @@ -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;