From 4932538c7461bf9d18cb8bf5dab21ac603dad107 Mon Sep 17 00:00:00 2001 From: axel Date: Wed, 10 May 2006 21:54:31 +1000 Subject: [PATCH] Add a few NULL checks to the codebase to avoid crashes on minor bugs darcs-hash:20060510115431-ac50b-f6b50fb29b95ff88e7504355aaffef1edcb6739d.gz --- parser.c | 14 +++++++++++--- tokenizer.c | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/parser.c b/parser.c index 2c93854b8..20bbe6dfa 100644 --- a/parser.c +++ b/parser.c @@ -1173,9 +1173,9 @@ wchar_t *parser_current_line() { int lineno=1; - const wchar_t *file = parser_current_filename(); - wchar_t *whole_str = tok_string( current_tokenizer ); - wchar_t *line = whole_str; + const wchar_t *file; + wchar_t *whole_str; + wchar_t *line; wchar_t *line_end; int i; int offset; @@ -1183,6 +1183,14 @@ wchar_t *parser_current_line() const wchar_t *function_name=0; int current_line_start=0; + if( !current_tokenizer ) + { + return L""; + } + + file = parser_current_filename(); + whole_str = tok_string( current_tokenizer ); + line = whole_str; if( !line ) return L""; diff --git a/tokenizer.c b/tokenizer.c index 8548852bd..92859d6a9 100644 --- a/tokenizer.c +++ b/tokenizer.c @@ -611,7 +611,7 @@ void tok_next( tokenizer *tok ) wchar_t *tok_string( tokenizer *tok ) { - return tok->orig_buff; + return tok?tok->orig_buff:0; } wchar_t *tok_first( const wchar_t *str )