From: Ingo Ruhnke Date: Fri, 6 Mar 2009 01:56:24 +0000 (+0000) Subject: Check that the userdata pointer is not null, which happens when a user creates a... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4eff38d2a777e7a889428eadbef0d1eae7d35db0;p=supertux.git 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 --- 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";