Minor fixes for possible leaks on uncommon code path or on initialization.

This commit is contained in:
Gregor Maier 2011-08-23 20:28:11 -07:00
parent 4214d8d905
commit f3a92ec30b
2 changed files with 10 additions and 1 deletions

View file

@ -444,6 +444,8 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
proto != IPPROTO_ICMP ) proto != IPPROTO_ICMP )
{ {
dump_this_packet = 1; dump_this_packet = 1;
if ( f )
Remove(t);
delete_tunnel_info(tunnel_info); delete_tunnel_info(tunnel_info);
return; return;
} }
@ -516,6 +518,8 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
default: default:
Weird(fmt("unknown_protocol %d", proto), hdr, pkt); Weird(fmt("unknown_protocol %d", proto), hdr, pkt);
if ( f )
Remove(f);
delete_tunnel_info(tunnel_info); delete_tunnel_info(tunnel_info);
return; return;
} }
@ -546,6 +550,8 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
if ( consistent < 0 ) if ( consistent < 0 )
{ {
delete h; delete h;
if ( f )
Remove(f);
delete_tunnel_info(tunnel_info); delete_tunnel_info(tunnel_info);
return; return;
} }
@ -571,6 +577,8 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
if ( ! conn ) if ( ! conn )
{ {
delete_tunnel_info(tunnel_info); delete_tunnel_info(tunnel_info);
if ( f )
Remove(f);
return; return;
} }

View file

@ -24,7 +24,8 @@ TunnelHandler::TunnelHandler(NetSessions *arg_s)
// lookup. // lookup.
for (int i=0; i< 65536; i++) for (int i=0; i< 65536; i++)
{ {
Unref(pv); if (pv)
Unref(pv);
pv = new PortVal(i, TRANSPORT_UDP); pv = new PortVal(i, TRANSPORT_UDP);
if (udp_tunnel_ports->Lookup(pv, false)) if (udp_tunnel_ports->Lookup(pv, false))
{ {