File tree Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Expand file tree Collapse file tree 2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -1011,8 +1011,6 @@ PHP_FUNCTION(ldap_connect)
1011
1011
RETURN_FALSE ;
1012
1012
}
1013
1013
1014
- object_init_ex (return_value , ldap_link_ce );
1015
- ld = Z_LDAP_LINK_P (return_value );
1016
1014
1017
1015
{
1018
1016
int rc = LDAP_SUCCESS ;
@@ -1035,13 +1033,17 @@ PHP_FUNCTION(ldap_connect)
1035
1033
1036
1034
/* ensure all pending TLS options are applied in a new context */
1037
1035
if (ldap_set_option (NULL , LDAP_OPT_X_TLS_NEWCTX , & val ) != LDAP_OPT_SUCCESS ) {
1038
- zval_ptr_dtor (return_value );
1036
+ if (url != host ) {
1037
+ efree (url );
1038
+ }
1039
1039
php_error_docref (NULL , E_WARNING , "Could not create new security context" );
1040
1040
RETURN_FALSE ;
1041
1041
}
1042
1042
LDAPG (tls_newctx ) = false;
1043
1043
}
1044
1044
#endif
1045
+ object_init_ex (return_value , ldap_link_ce );
1046
+ ld = Z_LDAP_LINK_P (return_value );
1045
1047
1046
1048
#ifdef LDAP_API_FEATURE_X_OPENLDAP
1047
1049
/* ldap_init() is deprecated, use ldap_initialize() instead.
@@ -1054,6 +1056,9 @@ PHP_FUNCTION(ldap_connect)
1054
1056
ldap = ldap_init (host , port );
1055
1057
if (ldap == NULL ) {
1056
1058
zval_ptr_dtor (return_value );
1059
+ if (url != host ) {
1060
+ efree (url );
1061
+ }
1057
1062
php_error_docref (NULL , E_WARNING , "Could not create session handle" );
1058
1063
RETURN_FALSE ;
1059
1064
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ ldap_connect() - Connection errors
3
+ --EXTENSIONS--
4
+ ldap
5
+ --INI--
6
+ error_reporting=E_ALL & ~E_DEPRECATED
7
+ --FILE--
8
+ <?php
9
+ require "connect.inc " ;
10
+ try {
11
+ ldap_connect ("nope:// $ host " , 65536 );
12
+ } catch (\ValueError $ e ) {
13
+ echo $ e ->getMessage (), PHP_EOL ;
14
+ }
15
+
16
+ try {
17
+ ldap_connect ("nope:// $ host " , 0 );
18
+ } catch (\ValueError $ e ) {
19
+ echo $ e ->getMessage (), PHP_EOL ;
20
+ }
21
+ ?>
22
+ --EXPECT--
23
+ ldap_connect(): Argument #2 ($port) must be between 1 and 65535
24
+ ldap_connect(): Argument #2 ($port) must be between 1 and 65535
You can’t perform that action at this time.
0 commit comments