Skip to content

Commit 900bdcb

Browse files
committed
Fix #78665: Multicasting may leak memory
1 parent 46561da commit 900bdcb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ PHP NEWS
1010
. Fixed bug #78642 (Wrong libiconv version displayed). (gedas at martynas,
1111
cmb).
1212

13+
- Sockets:
14+
. Fixed bug #78665 (Multicasting may leak memory). (cmb)
15+
1316
24 Oct 2019, PHP 7.2.24
1417

1518
- Core:

ext/sockets/multicast.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_add
652652
goto retry;
653653
}
654654
if (retval != NO_ERROR) {
655+
efree(addr_table);
655656
php_error_docref(NULL, E_WARNING,
656657
"GetIpAddrTable failed with error %lu", retval);
657658
return FAILURE;
@@ -660,9 +661,11 @@ int php_if_index_to_addr4(unsigned if_index, php_socket *php_sock, struct in_add
660661
MIB_IPADDRROW r = addr_table->table[i];
661662
if (r.dwIndex == if_index) {
662663
out_addr->s_addr = r.dwAddr;
664+
efree(addr_table);
663665
return SUCCESS;
664666
}
665667
}
668+
efree(addr_table);
666669
php_error_docref(NULL, E_WARNING,
667670
"No interface with index %u was found", if_index);
668671
return FAILURE;
@@ -692,6 +695,7 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i
692695
goto retry;
693696
}
694697
if (retval != NO_ERROR) {
698+
efree(addr_table);
695699
php_error_docref(NULL, E_WARNING,
696700
"GetIpAddrTable failed with error %lu", retval);
697701
return FAILURE;
@@ -700,9 +704,11 @@ int php_add4_to_if_index(struct in_addr *addr, php_socket *php_sock, unsigned *i
700704
MIB_IPADDRROW r = addr_table->table[i];
701705
if (r.dwAddr == addr->s_addr) {
702706
*if_index = r.dwIndex;
707+
efree(addr_table);
703708
return SUCCESS;
704709
}
705710
}
711+
efree(addr_table);
706712

707713
{
708714
char addr_str[17] = {0};

0 commit comments

Comments
 (0)