Simplify the redbean JSON encoder

This commit is contained in:
Justine Tunney 2022-04-29 06:35:27 -07:00
parent 2d1731b995
commit e4b559c76a
2 changed files with 17 additions and 23 deletions

View file

@ -130,6 +130,7 @@ static int LuaEncodeLuaDataImpl(lua_State *L, char **buf, int level,
fmt[4] = *numformat;
break;
default:
free(visited->p);
luaL_error(L, "numformat string not allowed");
unreachable;
}
@ -178,12 +179,12 @@ static int LuaEncodeLuaDataImpl(lua_State *L, char **buf, int level,
return 0;
default:
// TODO(jart): don't leak memory with longjmp
free(visited->p);
luaL_error(L, "can't serialize value of this type");
unreachable;
}
} else {
// TODO(jart): don't leak memory with longjmp
free(visited->p);
luaL_error(L, "too many nested tables");
unreachable;
}