]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
requestor: avoid calling close(-1) (Coverity)
authorDaniel Salzman <daniel.salzman@nic.cz>
Mon, 30 Jun 2025 04:52:46 +0000 (06:52 +0200)
committerDaniel Salzman <daniel.salzman@nic.cz>
Mon, 30 Jun 2025 04:55:48 +0000 (06:55 +0200)
src/knot/query/requestor.c

index 2a117162bd9aea4b80dd76c9a0a0fee8af5f4203..50b1675ad8028f0e67df24290c2de820ea04f546 100644 (file)
@@ -397,7 +397,7 @@ static int request_produce(knot_requestor_t *req, knot_request_t *last,
        }
 
        if (req->layer.state == KNOT_STATE_CONSUME) {
-               if ((last->flags & KNOT_REQUEST_NEW) &&
+               if ((last->flags & KNOT_REQUEST_NEW) && (last->fd >= 0) &&
                    !(last->flags & (KNOT_REQUEST_UDP | KNOT_REQUEST_TLS))) {
                        close(last->fd);
                        last->fd = -1;