@@ -2592,66 +2592,70 @@ PHP_FUNCTION(socket_addrinfo_lookup)
2592
2592
#endif
2593
2593
2594
2594
if (zhints ) {
2595
- if (!HT_IS_PACKED (Z_ARRVAL_P (zhints ))) {
2596
- ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (zhints ), key , hint ) {
2597
- if (key ) {
2598
- bool failed = false;
2599
- if (zend_string_equals_literal (key , "ai_flags ")) {
2600
- zend_long val = zval_try_get_long (hint , & failed );
2601
- if (failed ) {
2602
- zend_argument_type_error (3 , "\"ai_flags \" key must be of type int , %s given ", zend_zval_type_name (hint ));
2603
- RETURN_THROWS ();
2604
- }
2605
- if (val < 0 || val > INT_MAX ) {
2606
- zend_argument_value_error (3 , "\"ai_flags\" key must be between 0 and %d" , INT_MAX );
2607
- RETURN_THROWS ();
2608
- }
2609
- hints .ai_flags = (int )val ;
2610
- } else if (zend_string_equals_literal (key , "ai_socktype ")) {
2611
- zend_long val = zval_try_get_long (hint , & failed );
2612
- if (failed ) {
2613
- zend_argument_type_error (3 , "\"ai_socktype\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2614
- RETURN_THROWS ();
2615
- }
2616
- if (val < 0 || val > INT_MAX ) {
2617
- zend_argument_value_error (3 , "\"ai_socktype\" key must be between 0 and %d" , INT_MAX );
2618
- RETURN_THROWS ();
2619
- }
2620
- hints .ai_socktype = (int )val ;
2621
- } else if (zend_string_equals_literal (key , "ai_protocol ")) {
2622
- zend_long val = zval_try_get_long (hint , & failed );
2623
- if (failed ) {
2624
- zend_argument_type_error (3 , "\"ai_protocol\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2625
- RETURN_THROWS ();
2626
- }
2627
- if (val < 0 || val > INT_MAX ) {
2628
- zend_argument_value_error (3 , "\"ai_protocol\" key must be between 0 and %d" , INT_MAX );
2629
- RETURN_THROWS ();
2630
- }
2631
- hints .ai_protocol = (int )val ;
2632
- } else if (zend_string_equals_literal (key , "ai_family ")) {
2633
- zend_long val = zval_try_get_long (hint , & failed );
2634
- if (failed ) {
2635
- zend_argument_type_error (3 , "\"ai_family\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2636
- RETURN_THROWS ();
2637
- }
2638
- if (val < 0 || val >= AF_MAX ) {
2639
- zend_argument_value_error (3 , "\"ai_family\" key must be between 0 and %d" , AF_MAX - 1 );
2640
- RETURN_THROWS ();
2641
- }
2642
- hints .ai_family = (int )val ;
2643
- } else {
2644
- zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
2645
- "\"ai_protocol\", or \"ai_family\"" );
2646
- RETURN_THROWS ();
2647
- }
2648
- }
2649
- } ZEND_HASH_FOREACH_END ();
2650
- } else {
2595
+ if (HT_IS_PACKED (Z_ARRVAL_P (zhints ))) {
2651
2596
zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
2652
2597
"\"ai_protocol\", or \"ai_family\"" );
2653
2598
RETURN_THROWS ();
2654
2599
}
2600
+
2601
+ ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (zhints ), key , hint ) {
2602
+ if (key ) {
2603
+ bool failed = false;
2604
+ if (zend_string_equals_literal (key , "ai_flags" )) {
2605
+ zend_long val = zval_try_get_long (hint , & failed );
2606
+ if (failed ) {
2607
+ zend_argument_type_error (3 , "\"ai_flags\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2608
+ RETURN_THROWS ();
2609
+ }
2610
+ if (val < 0 || val > INT_MAX ) {
2611
+ zend_argument_value_error (3 , "\"ai_flags\" key must be between 0 and %d" , INT_MAX );
2612
+ RETURN_THROWS ();
2613
+ }
2614
+ hints .ai_flags = (int )val ;
2615
+ } else if (zend_string_equals_literal (key , "ai_socktype" )) {
2616
+ zend_long val = zval_try_get_long (hint , & failed );
2617
+ if (failed ) {
2618
+ zend_argument_type_error (3 , "\"ai_socktype\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2619
+ RETURN_THROWS ();
2620
+ }
2621
+ if (val < 0 || val > INT_MAX ) {
2622
+ zend_argument_value_error (3 , "\"ai_socktype\" key must be between 0 and %d" , INT_MAX );
2623
+ RETURN_THROWS ();
2624
+ }
2625
+ hints .ai_socktype = (int )val ;
2626
+ } else if (zend_string_equals_literal (key , "ai_protocol" )) {
2627
+ zend_long val = zval_try_get_long (hint , & failed );
2628
+ if (failed ) {
2629
+ zend_argument_type_error (3 , "\"ai_protocol\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2630
+ RETURN_THROWS ();
2631
+ }
2632
+ if (val < 0 || val > INT_MAX ) {
2633
+ zend_argument_value_error (3 , "\"ai_protocol\" key must be between 0 and %d" , INT_MAX );
2634
+ RETURN_THROWS ();
2635
+ }
2636
+ hints .ai_protocol = (int )val ;
2637
+ } else if (zend_string_equals_literal (key , "ai_family" )) {
2638
+ zend_long val = zval_try_get_long (hint , & failed );
2639
+ if (failed ) {
2640
+ zend_argument_type_error (3 , "\"ai_family\" key must be of type int, %s given" , zend_zval_type_name (hint ));
2641
+ RETURN_THROWS ();
2642
+ }
2643
+ if (val < 0 || val >= AF_MAX ) {
2644
+ zend_argument_value_error (3 , "\"ai_family\" key must be between 0 and %d" , AF_MAX - 1 );
2645
+ RETURN_THROWS ();
2646
+ }
2647
+ hints .ai_family = (int )val ;
2648
+ } else {
2649
+ zend_argument_value_error (3 , "must only contain array keys \"ai_flags\", \"ai_socktype\", "
2650
+ "\"ai_protocol\", or \"ai_family\"" );
2651
+ RETURN_THROWS ();
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 ();
2657
+ }
2658
+ } ZEND_HASH_FOREACH_END ();
2655
2659
}
2656
2660
2657
2661
if (getaddrinfo (ZSTR_VAL (hostname ), service , & hints , & result ) != 0 ) {
0 commit comments