(svn r13510) [NoAI] -Fix: be a tiny bit more strict for AIAbstract.Valuate() (check the type of the first 2 params) noai
authortruebrain
Fri, 13 Jun 2008 19:12:55 +0000
branchnoai
changeset 10956 82aa600a9922
parent 10955 56b381e5253f
child 10957 7a140b4cd91d
(svn r13510) [NoAI] -Fix: be a tiny bit more strict for AIAbstract.Valuate() (check the type of the first 2 params)
src/ai/api/ai_abstractlist.cpp
--- a/src/ai/api/ai_abstractlist.cpp	Fri Jun 13 15:43:39 2008 +0000
+++ b/src/ai/api/ai_abstractlist.cpp	Fri Jun 13 19:12:55 2008 +0000
@@ -547,6 +547,15 @@
 	sq_getstackobj(vm, 1, &obj_list);
 	sq_getstackobj(vm, 2, &obj_func);
 
+	if (sq_isclass(obj_list)) {
+		sq_throwerror(vm, _SC("parameter 1 has an invalid type (expected instance)"));
+		return -1;
+	}
+	if (sq_isfunction(obj_func)) {
+		sq_throwerror(vm, _SC("parameter 2 has an invalid type (expected function)"));
+		return -1;
+	}
+
 	/* Read the params */
 	HSQOBJECT *obj_params = AllocaM(HSQOBJECT, nparam);
 	for (int i = 0; i < nparam; i++) {