From: Quentin Young Date: Sat, 11 Jan 2020 20:16:21 +0000 (-0500) Subject: fix memleak in libfuzzer entrypoint X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=5b47db7c5e133a799389760d37a4d3fa24c07c14;p=matthieu%2Ffrr.git fix memleak in libfuzzer entrypoint --- diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 0284086ddd..be946cde04 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -494,8 +494,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) * BGP message is correct, and this check is performed by the i/o code, * so we need to make sure that remains true for fuzzed input. * */ - if (!validate_header(p)) - return 0; + if (!validate_header(p)) { + goto done; + } int result = 0; unsigned char pktbuf[BGP_MAX_PACKET_SIZE]; @@ -517,6 +518,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) result = bgp_process_packet(&t); } +done: peer_delete(p); FuzzingPeer = NULL;