Properly propagate errors when creating a DataView (fixes #1476)

The C++ code already threw an exception when creating a DataView with size 0, but the corresponding lua wrapper ignored it. Now it's correctly turned into a lua error.
This commit is contained in:
Bart van Strien
2019-03-02 13:47:49 +01:00
parent 4fd2009e25
commit 3d64ad0a3e
+2 -1
View File
@@ -62,7 +62,8 @@ int w_newDataView(lua_State *L)
if (offset < 0 || size < 0)
return luaL_error(L, "DataView offset and size must not be negative.");
DataView *d = instance()->newDataView(data, (size_t) offset, (size_t) size);
DataView *d;
luax_catchexcept(L, [&]() { d = instance()->newDataView(data, (size_t) offset, (size_t) size); });
luax_pushtype(L, d);
d->release();