From 3d64ad0a3ee4524a153745023d5abba90efd8b2f Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 2 Mar 2019 13:47:49 +0100 Subject: [PATCH] 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. --- src/modules/data/wrap_DataModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/data/wrap_DataModule.cpp b/src/modules/data/wrap_DataModule.cpp index 42fb1ba76..69604ddc7 100644 --- a/src/modules/data/wrap_DataModule.cpp +++ b/src/modules/data/wrap_DataModule.cpp @@ -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();