File tree 2 files changed +32
-3
lines changed
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -984,8 +984,6 @@ PHP_FUNCTION(ldap_connect)
984
984
RETURN_FALSE ;
985
985
}
986
986
987
- object_init_ex (return_value , ldap_link_ce );
988
- ld = Z_LDAP_LINK_P (return_value );
989
987
990
988
{
991
989
int rc = LDAP_SUCCESS ;
@@ -1008,13 +1006,17 @@ PHP_FUNCTION(ldap_connect)
1008
1006
1009
1007
/* ensure all pending TLS options are applied in a new context */
1010
1008
if (ldap_set_option (NULL , LDAP_OPT_X_TLS_NEWCTX , & val ) != LDAP_OPT_SUCCESS ) {
1011
- zval_ptr_dtor (return_value );
1009
+ if (url != host ) {
1010
+ efree (url );
1011
+ }
1012
1012
php_error_docref (NULL , E_WARNING , "Could not create new security context" );
1013
1013
RETURN_FALSE ;
1014
1014
}
1015
1015
LDAPG (tls_newctx ) = false;
1016
1016
}
1017
1017
#endif
1018
+ object_init_ex (return_value , ldap_link_ce );
1019
+ ld = Z_LDAP_LINK_P (return_value );
1018
1020
1019
1021
#ifdef LDAP_API_FEATURE_X_OPENLDAP
1020
1022
/* ldap_init() is deprecated, use ldap_initialize() instead.
@@ -1027,6 +1029,9 @@ PHP_FUNCTION(ldap_connect)
1027
1029
ldap = ldap_init (host , port );
1028
1030
if (ldap == NULL ) {
1029
1031
zval_ptr_dtor (return_value );
1032
+ if (url != host ) {
1033
+ efree (url );
1034
+ }
1030
1035
php_error_docref (NULL , E_WARNING , "Could not create session handle" );
1031
1036
RETURN_FALSE ;
1032
1037
}
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