@@ -1741,7 +1741,7 @@ PHP_FUNCTION(socket_get_option)
1741
1741
RETURN_FALSE ;
1742
1742
}
1743
1743
1744
- array_init (return_value );
1744
+ array_init_size (return_value , 2 );
1745
1745
1746
1746
add_assoc_string (return_value , "function_set_name" , tsf .function_set_name );
1747
1747
add_assoc_long (return_value , "pcbcnt" , tsf .pcbcnt );
@@ -1764,7 +1764,7 @@ PHP_FUNCTION(socket_get_option)
1764
1764
RETURN_FALSE ;
1765
1765
}
1766
1766
1767
- array_init (return_value );
1767
+ array_init_size (return_value , 2 );
1768
1768
add_assoc_long (return_value , "l_onoff" , linger_val .l_onoff );
1769
1769
add_assoc_long (return_value , "l_linger" , linger_val .l_linger );
1770
1770
return ;
@@ -1786,7 +1786,7 @@ PHP_FUNCTION(socket_get_option)
1786
1786
tv .tv_usec = timeout ? (long )((timeout % 1000 ) * 1000 ) : 0 ;
1787
1787
#endif
1788
1788
1789
- array_init (return_value );
1789
+ array_init_size (return_value , 2 );
1790
1790
1791
1791
add_assoc_long (return_value , "sec" , tv .tv_sec );
1792
1792
add_assoc_long (return_value , "usec" , tv .tv_usec );
@@ -1808,7 +1808,7 @@ PHP_FUNCTION(socket_get_option)
1808
1808
RETURN_FALSE ;
1809
1809
}
1810
1810
1811
- array_init (return_value );
1811
+ array_init_size (return_value , 9 );
1812
1812
1813
1813
add_assoc_long (return_value , "rmem_alloc" , minfo [SK_MEMINFO_RMEM_ALLOC ]);
1814
1814
add_assoc_long (return_value , "rcvbuf" , minfo [SK_MEMINFO_RCVBUF ]);
@@ -1833,7 +1833,7 @@ PHP_FUNCTION(socket_get_option)
1833
1833
RETURN_FALSE ;
1834
1834
}
1835
1835
1836
- array_init (return_value );
1836
+ array_init_size (return_value , 1 );
1837
1837
1838
1838
add_assoc_string (return_value , "af_name" , af .af_name );
1839
1839
return ;
@@ -1857,9 +1857,11 @@ PHP_FUNCTION(socket_get_option)
1857
1857
RETURN_FALSE ;
1858
1858
}
1859
1859
1860
- array_init (return_value );
1860
+ size_t arrlen = optlen / sizeof (struct fil_info );
1861
+
1862
+ array_init_size (return_value , arrlen );
1861
1863
1862
- for (i = 0 ; i < optlen / sizeof ( struct fil_info ) ; i ++ ) {
1864
+ for (i = 0 ; i < arrlen ; i ++ ) {
1863
1865
add_index_string (return_value , i , fi [i ].fi_name );
1864
1866
}
1865
1867
@@ -2589,7 +2591,13 @@ PHP_FUNCTION(socket_addrinfo_lookup)
2589
2591
# endif
2590
2592
#endif
2591
2593
2592
- if (zhints && !HT_IS_PACKED (Z_ARRVAL_P (zhints ))) {
2594
+ if (zhints ) {
2595
+ if (UNEXPECTED (HT_IS_PACKED (Z_ARRVAL_P (zhints )))) {
2596
+ zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
2597
+ "\"ai_protocol\", or \"ai_family\"" );
2598
+ RETURN_THROWS ();
2599
+ }
2600
+
2593
2601
ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (zhints ), key , hint ) {
2594
2602
if (key ) {
2595
2603
bool failed = false;
@@ -2639,9 +2647,13 @@ PHP_FUNCTION(socket_addrinfo_lookup)
2639
2647
hints .ai_family = (int )val ;
2640
2648
} else {
2641
2649
zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
2642
- "\"ai_protocol\", or \"ai_family\"" );
2650
+ "\"ai_protocol\", or \"ai_family\"" );
2643
2651
RETURN_THROWS ();
2644
- }
2652
+ }
2653
+ } else {
2654
+ zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
2655
+ "\"ai_protocol\", or \"ai_family\"" );
2656
+ RETURN_THROWS ();
2645
2657
}
2646
2658
} ZEND_HASH_FOREACH_END ();
2647
2659
}
0 commit comments