Commit 8f1155b8 authored by Petr Špaček's avatar Petr Špaček

doh: fix memory leaks

parent 161dc335
......@@ -14,6 +14,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "contrib/cleanup.h"
#include "daemon/bindings/impl.h"
#include "daemon/worker.h"
......@@ -60,11 +62,11 @@ static int wrk_resolve_pkt(lua_State *L)
// FIXME: merge with wrk_resolve
const struct kr_qflags options = {};
knot_pkt_t *pkt = *(knot_pkt_t **)lua_topointer(L, 1);
printf("%p\n", pkt);
if (!pkt)
lua_error_maybe(L, ENOMEM);
printf("%s\n", kr_pkt_text(pkt));
auto_free char *debug = kr_pkt_text(pkt);
printf("%s\n", debug);
/* Create task and start with a first question */
......
......@@ -70,7 +70,7 @@ local function serve_doh(h, stream)
-- convert query to knot_pkt_t
local wire = ffi.cast("void *", input)
local pkt = ffi.C.knot_pkt_new(wire, #input, nil);
local pkt = ffi.gc(ffi.C.knot_pkt_new(wire, #input, nil), ffi.C.knot_pkt_free)
if not pkt then
return 500, 'internal server error'
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment