From b7c5af7e64b3e4fa631ef14fcf5165891c8e1351 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Mon, 6 Feb 2012 13:59:02 -0800 Subject: [PATCH] Prohibit returning functions from functions. (Fix malformed program crasher) --- decl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/decl.cpp b/decl.cpp index ec8022b7..beff32d8 100644 --- a/decl.cpp +++ b/decl.cpp @@ -447,6 +447,10 @@ Declarator::GetType(const Type *base, DeclSpecs *ds) const { Error(pos, "No return type provided in function declaration."); return NULL; } + if (dynamic_cast(returnType) != NULL) { + Error(pos, "Illegal to return function type from function."); + return NULL; + } bool isExported = ds && (ds->storageClass == SC_EXPORT); bool isExternC = ds && (ds->storageClass == SC_EXTERN_C);