MCPcopy Create free account
hub / github.com/axmolengine/axmol / json_check_encode_depth

Function json_check_encode_depth

3rdparty/lua/lua-cjson/lua_cjson.c:547–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

545}
546
547static void json_check_encode_depth(lua_State *l, json_config_t *cfg,
548 int current_depth, strbuf_t *json)
549{
550 /* Ensure there are enough slots free to traverse a table (key,
551 * value) and push a string for a potential error message.
552 *
553 * Unlike "decode", the key and value are still on the stack when
554 * lua_checkstack() is called. Hence an extra slot for luaL_error()
555 * below is required just in case the next check to lua_checkstack()
556 * fails.
557 *
558 * While this won't cause a crash due to the EXTRA_STACK reserve
559 * slots, it would still be an improper use of the API. */
560 if (current_depth <= cfg->encode_max_depth && lua_checkstack(l, 3))
561 return;
562
563 if (!cfg->encode_keep_buffer)
564 strbuf_free(json);
565
566 luaL_error(l, "Cannot serialise, excessive nesting (%d)",
567 current_depth);
568}
569
570static void json_append_data(lua_State *l, json_config_t *cfg,
571 int current_depth, strbuf_t *json);

Callers 1

json_append_dataFunction · 0.85

Calls 3

lua_checkstackFunction · 0.85
strbuf_freeFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected