[Tarantool-patches] [PATCH] net.box: allow to store user-defined fields in future object

Cyrill Gorcunov gorcunov at gmail.com
Tue Aug 10 20:15:27 MSK 2021


On Tue, Aug 10, 2021 at 07:53:54PM +0300, Vladimir Davydov via Tarantool-patches wrote:
> +
> +static int
> +luaT_netbox_request_newindex(struct lua_State *L)
> +{
> +	struct netbox_request *request = luaT_check_netbox_request(L, 1);
> +	struct mh_strnptr_t *h = request->index;
> +	size_t field_name_len;
> +	const char *field_name = lua_tolstring(L, 2, &field_name_len);
> +	if (field_name == NULL)
> +		return luaL_error(L, "invalid index");
> +	int field_value_ref = luaL_ref(L, LUA_REGISTRYINDEX);
> +	if (field_value_ref == LUA_REFNIL) {
> +		/* The field is set to nil. Delete it from the index. */
> +		if (h == NULL)
> +			return 0;
> +		mh_int_t k = mh_strnptr_find_inp(h, field_name,
> +						 field_name_len);

We're guaranteed that field_name present in a hash and never
ever return nil, right? Sorry I don't understand this code just
found this moment suspicious.


More information about the Tarantool-patches mailing list