Browse Source

better error checking for Data:getString's size parameter.

Sasha Szpakowski 2 years ago
parent
commit
139c68d197
1 changed files with 3 additions and 0 deletions
  1. 3 0
      src/modules/data/wrap_Data.cpp

+ 3 - 0
src/modules/data/wrap_Data.cpp

@@ -45,6 +45,9 @@ int w_Data_getString(lua_State *L)
 		? ((int64) t->getSize() - offset)
 		? ((int64) t->getSize() - offset)
 		: (int64) luaL_checknumber(L, 3);
 		: (int64) luaL_checknumber(L, 3);
 
 
+	if (size <= 0)
+		return luaL_error(L, "Invalid size parameter (must be greater than 0)");
+
 	if (offset < 0 || offset + size > (int64) t->getSize())
 	if (offset < 0 || offset + size > (int64) t->getSize())
 		return luaL_error(L, "The given offset and size parameters don't fit within the Data's size.");
 		return luaL_error(L, "The given offset and size parameters don't fit within the Data's size.");