From 37cdc18639d88b14ed9927622d7ee212f142a515 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 27 Jan 2012 10:01:06 -0800 Subject: [PATCH] Issue error instead of crashing given attempted function call through non-function. Fixes issue #163. --- expr.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/expr.cpp b/expr.cpp index c424f3c2..b04c8319 100644 --- a/expr.cpp +++ b/expr.cpp @@ -2678,12 +2678,12 @@ FunctionCallExpr::TypeCheck() { const Type *fptrType = func->GetType(); if (fptrType == NULL) return NULL; - - Assert(dynamic_cast(fptrType) != NULL); - const FunctionType *funcType = - dynamic_cast(fptrType->GetBaseType()); - if (funcType == NULL) { - Error(pos, "Must provide function name or function pointer for " + + // Make sure we do in fact have a function to call + const FunctionType *funcType; + if (dynamic_cast(fptrType) == NULL || + (funcType = dynamic_cast(fptrType->GetBaseType())) == NULL) { + Error(func->pos, "Must provide function name or function pointer for " "function call expression."); return NULL; }