diff options
author | 2006-05-10 21:54:31 +1000 | |
---|---|---|
committer | 2006-05-10 21:54:31 +1000 | |
commit | 4932538c7461bf9d18cb8bf5dab21ac603dad107 (patch) | |
tree | 551c1ddc5718dd69a16fcabd254ec1de8baa7913 | |
parent | 786144ba86af6abd290c2b63977ec6d8cf5df62a (diff) |
Add a few NULL checks to the codebase to avoid crashes on minor bugs
darcs-hash:20060510115431-ac50b-f6b50fb29b95ff88e7504355aaffef1edcb6739d.gz
-rw-r--r-- | parser.c | 14 | ||||
-rw-r--r-- | tokenizer.c | 2 |
2 files changed, 12 insertions, 4 deletions
@@ -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 8548852b..92859d6a 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 ) |