mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-08-17 21:25:50 +02:00
fix memory leak in unbound-streamtcp when open_svr failed
==1927474== Memcheck, a memory error detector ==1927474== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==1927474== Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info ==1927474== Command: unbound-streamtcp -f localhost ==1927474== fatal: bad server specs 'localhost' ==1927474== ==1927474== HEAP SUMMARY: ==1927474== in use at exit: 131,186 bytes in 4 blocks ==1927474== total heap usage: 5 allocs, 1 frees, 132,210 bytes allocated ==1927474== ==1927474== 40 bytes in 1 blocks are still reachable in loss record 1 of 4 ==1927474== at 0x483F751: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==1927474== by 0x1E0573: sldns_buffer_new (sbuffer.c:21) ==1927474== by 0x11ECED: send_em (streamtcp.c:374) ==1927474== by 0x11E6C1: main (streamtcp.c:585) ==1927474== ==1927474== 40 bytes in 1 blocks are still reachable in loss record 2 of 4 ==1927474== at 0x483F751: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==1927474== by 0x1E0573: sldns_buffer_new (sbuffer.c:21) ==1927474== by 0x11ECFA: send_em (streamtcp.c:375) ==1927474== by 0x11E6C1: main (streamtcp.c:585) ==1927474== ==1927474== 65,553 bytes in 1 blocks are still reachable in loss record 3 of 4 ==1927474== at 0x483F751: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==1927474== by 0x1E0583: sldns_buffer_new (sbuffer.c:27) ==1927474== by 0x11ECED: send_em (streamtcp.c:374) ==1927474== by 0x11E6C1: main (streamtcp.c:585) ==1927474== ==1927474== 65,553 bytes in 1 blocks are still reachable in loss record 4 of 4 ==1927474== at 0x483F751: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==1927474== by 0x1E0583: sldns_buffer_new (sbuffer.c:27) ==1927474== by 0x11ECFA: send_em (streamtcp.c:375) ==1927474== by 0x11E6C1: main (streamtcp.c:585) ==1927474== ==1927474== LEAK SUMMARY: ==1927474== definitely lost: 0 bytes in 0 blocks ==1927474== indirectly lost: 0 bytes in 0 blocks ==1927474== possibly lost: 0 bytes in 0 blocks ==1927474== still reachable: 131,186 bytes in 4 blocks ==1927474== suppressed: 0 bytes in 0 blocks ==1927474== ==1927474== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) Signed-off-by: eaglegai <eaglegai@163.com>
This commit is contained in:
@@ -371,15 +371,19 @@ static void
|
||||
send_em(const char* svr, const char* pp2_client, int udp, int usessl,
|
||||
int noanswer, int onarrival, int delay, int num, char** qs)
|
||||
{
|
||||
sldns_buffer* buf = sldns_buffer_new(65553);
|
||||
sldns_buffer* proxy_buf = sldns_buffer_new(65553);
|
||||
struct sockaddr_storage svr_addr;
|
||||
socklen_t svr_addrlen;
|
||||
int fd = open_svr(svr, udp, &svr_addr, &svr_addrlen);
|
||||
int i, wait_results = 0, pp2_parsed;
|
||||
SSL_CTX* ctx = NULL;
|
||||
SSL* ssl = NULL;
|
||||
sldns_buffer* buf = sldns_buffer_new(65553);
|
||||
if(!buf) fatal_exit("out of memory");
|
||||
sldns_buffer* proxy_buf = sldns_buffer_new(65553);
|
||||
if(!proxy_buf) {
|
||||
sldns_buffer_free(buf);
|
||||
fatal_exit("out of memory");
|
||||
}
|
||||
pp2_parsed = parse_pp2_client(pp2_client, udp, proxy_buf);
|
||||
if(usessl) {
|
||||
ctx = connect_sslctx_create(NULL, NULL, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user