From 4eff38d2a777e7a889428eadbef0d1eae7d35db0 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Fri, 6 Mar 2009 01:56:24 +0000 Subject: [PATCH] Check that the userdata pointer is not null, which happens when a user creates a C++ class himself on the Squirrel side via the constructor (i.e. a <- GameObject()) SVN-Revision: 5845 --- tools/miniswig/create_wrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/miniswig/create_wrapper.cpp b/tools/miniswig/create_wrapper.cpp index a31663166..29f35b2a1 100644 --- a/tools/miniswig/create_wrapper.cpp +++ b/tools/miniswig/create_wrapper.cpp @@ -304,7 +304,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function) // retrieve pointer to class instance if(_class != 0 && function->type != Function::CONSTRUCTOR) { out << ind << "SQUserPointer data;\n"; - out << ind << "if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) {\n"; + out << ind << "if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0)) || !data) {\n"; out << ind << ind << "sq_throwerror(vm, _SC(\"'" << function->name << "' called without instance\"));\n"; out << ind << ind << "return SQ_ERROR;\n"; out << ind << "}\n"; -- 2.11.0