wpcap: Fix crash on pcap_loop.

Signed-off-by: Jianqiu Zhang <zhangjianqiu_133@yeah.net>
Signed-off-by: André Hentschel <nerv@dawncrow.de>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jianqiu Zhang 2016-01-05 09:12:42 +08:00 committed by Alexandre Julliard
parent d8eac06940
commit eacc448f6c
1 changed files with 8 additions and 11 deletions

View File

@ -95,7 +95,6 @@ static void pcap_handler_callback(u_char *user_data, const struct pcap_pkthdr *h
TRACE("(%p %p %p)\n", user_data, h, p);
pcb = (PCAP_HANDLER_CALLBACK *)user_data;
pcb->pfn_cb(pcb->user_data, h, p);
HeapFree(GetProcessHeap(), 0, pcb);
TRACE("Callback COMPLETED\n");
}
@ -107,11 +106,10 @@ int CDECL wine_pcap_dispatch(pcap_t *p, int cnt,
if (callback)
{
PCAP_HANDLER_CALLBACK *pcb;
pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
pcb->pfn_cb = callback;
pcb->user_data = user;
return pcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
PCAP_HANDLER_CALLBACK pcb;
pcb.pfn_cb = callback;
pcb.user_data = user;
return pcap_dispatch(p, cnt, pcap_handler_callback, (unsigned char *)&pcb);
}
return pcap_dispatch(p, cnt, NULL, user);
@ -200,11 +198,10 @@ int CDECL wine_pcap_loop(pcap_t *p, int cnt,
if (callback)
{
PCAP_HANDLER_CALLBACK *pcb;
pcb = HeapAlloc(GetProcessHeap(), 0, sizeof(PCAP_HANDLER_CALLBACK));
pcb->pfn_cb = callback;
pcb->user_data = user;
return pcap_loop(p, cnt, pcap_handler_callback, (unsigned char*)pcb);
PCAP_HANDLER_CALLBACK pcb;
pcb.pfn_cb = callback;
pcb.user_data = user;
return pcap_loop(p, cnt, pcap_handler_callback, (unsigned char *)&pcb);
}
return pcap_loop(p, cnt, NULL, user);