Ensure Blob size is positive;

This commit is contained in:
bjorn 2019-02-17 18:43:52 -08:00
parent 0cba1ba28d
commit af155ff0c5
1 changed files with 3 additions and 1 deletions

View File

@ -11,7 +11,9 @@ static int l_lovrDataNewBlob(lua_State* L) {
uint8_t* data = NULL;
int type = lua_type(L, 1);
if (type == LUA_TNUMBER) {
size = lua_tonumber(L, 1);
int isize = lua_tonumber(L, 1);
lovrAssert(isize > 0, "Blob size must be positive");
size = (size_t) isize;
data = calloc(1, size);
lovrAssert(data, "Out of memory");
} else if (type == LUA_TSTRING) {