From e667485f6813f1f1f4ed8c8370df0e06ddba7305 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 26 Apr 2014 14:35:39 +0200 Subject: [PATCH] Check argument count of newChainShape --- src/modules/physics/box2d/Physics.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/physics/box2d/Physics.cpp b/src/modules/physics/box2d/Physics.cpp index a76aca20f..a016c7a05 100644 --- a/src/modules/physics/box2d/Physics.cpp +++ b/src/modules/physics/box2d/Physics.cpp @@ -133,12 +133,12 @@ int Physics::newPolygonShape(lua_State *L) int Physics::newChainShape(lua_State *L) { int argc = lua_gettop(L)-1; // first argument is looping + if (argc % 2 != 0) + return luaL_error(L, "Number of vertex components must be a multiple of two."); + int vcount = (int)argc/2; - b2ChainShape *s = new b2ChainShape(); - bool loop = luax_toboolean(L, 1); - b2Vec2 *vecs = new b2Vec2[vcount]; for (int i = 0; i