[tarantool-patches] Re: [PATCH v2 2/6] Add functions to ease using Lua iterators from C

  • From: Alexander Turenko <alexander.turenko@xxxxxxxxxxxxx>
  • To: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
  • Date: Mon, 28 Jan 2019 21:17:16 +0300

Updated a bit:

diff --git a/src/lua/utils.c b/src/lua/utils.c
index 173d59a59..c8cfa70b3 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -981,6 +981,11 @@ struct luaL_iterator *
 luaL_iterator_new(lua_State *L, int idx)
 {
        struct luaL_iterator *it = malloc(sizeof(struct luaL_iterator));
+       if (it == NULL) {
+               diag_set(OutOfMemory, sizeof(struct luaL_iterator),
+                        "malloc", "luaL_iterator");
+               return NULL;
+       }
 
        if (idx == 0) {
                /* gen, param, state are on top of a Lua stack. */

Other related posts: