From 860299f9411cb54e7932f3a0f1f83d2942689e81 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Tue, 11 Jun 2024 23:09:52 +0100 Subject: [PATCH] ext/sockets: multicast simplification on ipv4 table retrieval and buffer handling. --- ext/sockets/multicast.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ext/sockets/multicast.c b/ext/sockets/multicast.c index a348aa14b556c..4eefb33b694bc 100644 --- a/ext/sockets/multicast.c +++ b/ext/sockets/multicast.c @@ -619,8 +619,8 @@ static int _php_source_op_to_ipv4_op(enum source_op sop) zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr) { MIB_IPADDRTABLE *addr_table; - ULONG size; - DWORD retval; + ULONG size; + DWORD retval; DWORD i; (void) php_sock; /* not necessary */ @@ -635,8 +635,7 @@ zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struc retry: retval = GetIpAddrTable(addr_table, &size, 0); if (retval == ERROR_INSUFFICIENT_BUFFER) { - efree(addr_table); - addr_table = emalloc(size); + erealloc(addr_table, size); goto retry; } if (retval != NO_ERROR) { @@ -662,8 +661,8 @@ zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struc zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index) { MIB_IPADDRTABLE *addr_table; - ULONG size; - DWORD retval; + ULONG size; + DWORD retval; DWORD i; (void) php_sock; /* not necessary */ @@ -678,8 +677,7 @@ zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, uns retry: retval = GetIpAddrTable(addr_table, &size, 0); if (retval == ERROR_INSUFFICIENT_BUFFER) { - efree(addr_table); - addr_table = emalloc(size); + erealloc(addr_table, size); goto retry; } if (retval != NO_ERROR) {