]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Coverity: 1419402 Uncaught exception 11495/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 1 Apr 2022 12:48:05 +0000 (14:48 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 1 Apr 2022 12:55:30 +0000 (14:55 +0200)
Catch any exception that might be thrown when (copy) constructing an object.
As the push method is declared `noexcept` we cannot have that.

ext/luawrapper/include/LuaContext.hpp

index 9f8d473fb7822bacd2545a9e9c7f61400947f78a..ad6c86e556fe126d7013146125bee220a6111dbf 100644 (file)
@@ -1639,12 +1639,18 @@ private:
 
             // writing structure for this type into the registry
             checkTypeRegistration(state, &typeid(TType));
+            try {
+              // creating the object
+              // lua_newuserdata allocates memory in the internals of the lua library and returns it so we can fill it
+              //   and that's what we do with placement-new
+              const auto pointerLocation = static_cast<TType*>(lua_newuserdata(state, sizeof(TType)));
+              new (pointerLocation) TType(std::forward<TType2>(value));
+            }
+            catch (...) {
+              Pusher<std::exception_ptr>::push(state, std::current_exception()).release();
+              luaError(state);
+            }
 
-            // creating the object
-            // lua_newuserdata allocates memory in the internals of the lua library and returns it so we can fill it
-            //   and that's what we do with placement-new
-            const auto pointerLocation = static_cast<TType*>(lua_newuserdata(state, sizeof(TType)));
-            new (pointerLocation) TType(std::forward<TType2>(value));
             PushedObject obj{state, 1};
 
             // creating the metatable (over the object on the stack)