diff --git a/src/api/data.c b/src/api/data.c index c6ad547b..ab823b04 100644 --- a/src/api/data.c +++ b/src/api/data.c @@ -24,11 +24,15 @@ int l_lovrDataNewBlob(lua_State* L) { if (type == LUA_TNUMBER) { size = lua_tonumber(L, 1); data = calloc(1, size); - } else { + } else if (type == LUA_TSTRING) { const char* str = luaL_checklstring(L, 1, &size); data = malloc(size + 1); memcpy(data, str, size); data[size] = '\0'; + } else { + Blob* blob = luax_checktypeof(L, 1, Blob); + size = blob->size; + data = malloc(size); } const char* name = luaL_optstring(L, 2, ""); Blob* blob = lovrBlobCreate(data, size, name);