Skip to content

Commit 18cfd94

Browse files
authored
ext/sockets: multicast simplification on ipv4 table retrieval and buffer handling. (#14542)
1 parent 25360ef commit 18cfd94

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

ext/sockets/multicast.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,8 @@ static int _php_source_op_to_ipv4_op(enum source_op sop)
619619
zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_addr *out_addr)
620620
{
621621
MIB_IPADDRTABLE *addr_table;
622-
ULONG size;
623-
DWORD retval;
622+
ULONG size;
623+
DWORD retval;
624624
DWORD i;
625625

626626
(void) php_sock; /* not necessary */
@@ -635,8 +635,7 @@ zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struc
635635
retry:
636636
retval = GetIpAddrTable(addr_table, &size, 0);
637637
if (retval == ERROR_INSUFFICIENT_BUFFER) {
638-
efree(addr_table);
639-
addr_table = emalloc(size);
638+
erealloc(addr_table, size);
640639
goto retry;
641640
}
642641
if (retval != NO_ERROR) {
@@ -662,8 +661,8 @@ zend_result php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struc
662661
zend_result php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *if_index)
663662
{
664663
MIB_IPADDRTABLE *addr_table;
665-
ULONG size;
666-
DWORD retval;
664+
ULONG size;
665+
DWORD retval;
667666
DWORD i;
668667

669668
(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
678677
retry:
679678
retval = GetIpAddrTable(addr_table, &size, 0);
680679
if (retval == ERROR_INSUFFICIENT_BUFFER) {
681-
efree(addr_table);
682-
addr_table = emalloc(size);
680+
erealloc(addr_table, size);
683681
goto retry;
684682
}
685683
if (retval != NO_ERROR) {

0 commit comments

Comments
 (0)