summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo Buehler <tb@cvs.openbsd.org>2022-11-27 14:31:23 +0000
committerTheo Buehler <tb@cvs.openbsd.org>2022-11-27 14:31:23 +0000
commit6735890bae2db0e95abf056e61d332c892cfaf49 (patch)
tree4e9ef86ac433bc23e3714b4b12ea19db70bfde9d
parentd8b4c11622b216475eb16365853ccb89cf6f5b34 (diff)
Plug leak of tmp in case allocation of pq->abuf fails
ok florian
-rw-r--r--sbin/unwind/frontend.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sbin/unwind/frontend.c b/sbin/unwind/frontend.c
index c241a6c82e9..e7578852ea3 100644
--- a/sbin/unwind/frontend.c
+++ b/sbin/unwind/frontend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: frontend.c,v 1.75 2022/11/27 14:29:06 tb Exp $ */
+/* $OpenBSD: frontend.c,v 1.76 2022/11/27 14:31:22 tb Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -1707,10 +1707,13 @@ tcp_request(int fd, short events, void *arg)
sldns_buffer_flip(pq->qbuf);
len = sldns_buffer_read_u16(pq->qbuf);
tmp = sldns_buffer_new(len);
+ if (tmp == NULL)
+ goto fail;
pq->abuf = sldns_buffer_new(len);
-
- if (!tmp || !pq->abuf)
+ if (pq->abuf == NULL) {
+ sldns_buffer_free(tmp);
goto fail;
+ }
rem = sldns_buffer_remaining(pq->qbuf);
sldns_buffer_write(tmp, sldns_buffer_current(pq->qbuf),