]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
cache.clear('name'): fix a small GC race
authorVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 12 Sep 2018 06:51:50 +0000 (08:51 +0200)
committerPetr Špaček <petr.spacek@nic.cz>
Wed, 31 Oct 2018 14:29:42 +0000 (14:29 +0000)
Thanks to Marek for noticing it.

daemon/lua/sandbox.lua

index 131732402270aa8881b4296cfe209d63c42bdb15..f10d5a777b601902c9c4662385d43bb9bdeb0b13 100644 (file)
@@ -184,13 +184,13 @@ cache.clear = function (name, exact_name, rr_type, chunk_size, callback, prev_st
                local ret = ffi.C.kr_cache_closest_apex(cach, dname, false, apex_array)
                if ret < 0 then
                        error(ffi.string(ffi.C.knot_strerror(ret))) end
-               ffi.gc(apex_array[0], ffi.C.free)
                if not ffi.C.knot_dname_is_equal(apex_array[0], dname) then
                        local apex_str = kres.dname2str(apex_array[0])
                        rettable.not_apex = 'to clear proofs of non-existence call '
                                .. 'cache.clear(\'' .. tostring(apex_str) ..'\')'
                        rettable.subtree = apex_str
                end
+               ffi.C.free(apex_array[0])
        end
 
        if rr_type ~= nil then