Commit 2e540b50 by Ian Lance Taylor

compiler: fix null-dereference on invalid len() arg.

This patch fixes an ICE caused by syntax errors in arguments
to unary built-in functions like len().

Updates issue 7.

From Rémy Oudompheng.

From-SVN: r185935
parent 1fbb888c
...@@ -6609,7 +6609,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, ...@@ -6609,7 +6609,7 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
if (this->code_ == BUILTIN_LEN || this->code_ == BUILTIN_CAP) if (this->code_ == BUILTIN_LEN || this->code_ == BUILTIN_CAP)
{ {
Expression* arg = this->one_arg(); Expression* arg = this->one_arg();
if (!arg->is_constant()) if (arg != NULL && !arg->is_constant())
{ {
Find_call_expression find_call; Find_call_expression find_call;
Expression::traverse(&arg, &find_call); Expression::traverse(&arg, &find_call);
...@@ -6929,7 +6929,7 @@ Expression* ...@@ -6929,7 +6929,7 @@ Expression*
Builtin_call_expression::one_arg() const Builtin_call_expression::one_arg() const
{ {
const Expression_list* args = this->args(); const Expression_list* args = this->args();
if (args->size() != 1) if (args == NULL || args->size() != 1)
return NULL; return NULL;
return args->front(); return args->front();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment