Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
e24bcef1
Commit
e24bcef1
authored
Jun 10, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Jun 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wldap32: Clean up LDAP_OPT_API_INFO.
Fix memory leaks on error paths, don't call memset unnecessarily, and ensure that all output fields are initialized.
parent
272f712b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
33 deletions
+44
-33
option.c
dlls/wldap32/option.c
+44
-33
No files found.
dlls/wldap32/option.c
View file @
e24bcef1
...
...
@@ -63,28 +63,33 @@ ULONG CDECL ldap_get_optionA( LDAP *ld, int option, void *value )
LDAPAPIInfoW
infoW
;
LDAPAPIInfoA
*
infoA
=
value
;
memset
(
&
infoW
,
0
,
sizeof
(
infoW
)
);
infoW
.
ldapai_info_version
=
infoA
->
ldapai_info_version
;
ret
=
ldap_get_optionW
(
ld
,
option
,
&
infoW
);
if
(
ret
==
WLDAP32_LDAP_SUCCESS
)
{
infoA
->
ldapai_api_version
=
infoW
.
ldapai_api_version
;
infoA
->
ldapai_protocol_version
=
infoW
.
ldapai_protocol_version
;
if
(
ret
!=
WLDAP32_LDAP_SUCCESS
)
return
ret
;
if
(
infoW
.
ldapai_extensions
&&
!
(
infoA
->
ldapai_extensions
=
strarrayWtoA
(
infoW
.
ldapai_extensions
)))
return
WLDAP32_LDAP_NO_MEMORY
;
if
(
infoW
.
ldapai_vendor_name
&&
!
(
infoA
->
ldapai_vendor_name
=
strWtoA
(
infoW
.
ldapai_vendor_name
)))
{
ldap_value_freeW
(
infoW
.
ldapai_extensions
);
return
WLDAP32_LDAP_NO_MEMORY
;
}
infoA
->
ldapai_vendor_version
=
infoW
.
ldapai_vendor_version
;
infoA
->
ldapai_extensions
=
strarrayWtoA
(
infoW
.
ldapai_extensions
);
if
(
infoW
.
ldapai_extensions
&&
!
infoA
->
ldapai_extensions
)
{
strarrayfreeW
(
infoW
.
ldapai_extensions
);
free
(
infoW
.
ldapai_vendor_name
);
return
WLDAP32_LDAP_NO_MEMORY
;
}
ldap_value_freeW
(
infoW
.
ldapai_extensions
);
ldap_memfreeW
(
infoW
.
ldapai_vendor_name
);
infoA
->
ldapai_vendor_name
=
strWtoA
(
infoW
.
ldapai_vendor_name
);
if
(
infoW
.
ldapai_vendor_name
&&
!
infoA
->
ldapai_vendor_name
)
{
strarrayfreeW
(
infoW
.
ldapai_extensions
);
free
(
infoW
.
ldapai_vendor_name
);
strarrayfreeA
(
infoA
->
ldapai_extensions
);
return
WLDAP32_LDAP_NO_MEMORY
;
}
return
ret
;
infoA
->
ldapai_api_version
=
infoW
.
ldapai_api_version
;
infoA
->
ldapai_protocol_version
=
infoW
.
ldapai_protocol_version
;
infoA
->
ldapai_vendor_version
=
infoW
.
ldapai_vendor_version
;
return
WLDAP32_LDAP_SUCCESS
;
}
case
WLDAP32_LDAP_OPT_DEREF
:
...
...
@@ -184,28 +189,34 @@ ULONG CDECL ldap_get_optionW( LDAP *ld, int option, void *value )
LDAPAPIInfo
infoU
;
LDAPAPIInfoW
*
infoW
=
value
;
memset
(
&
infoU
,
0
,
sizeof
(
infoU
)
);
infoU
.
ldapai_info_version
=
infoW
->
ldapai_info_version
;
ret
=
map_error
(
ldap_get_option
(
CTX
(
ld
),
option
,
&
infoU
)
);
if
(
ret
==
WLDAP32_LDAP_SUCCESS
)
{
infoW
->
ldapai_api_version
=
infoU
.
ldapai_api_version
;
infoW
->
ldapai_protocol_version
=
infoU
.
ldapai_protocol_version
;
ret
=
ldap_get_option
(
CTX
(
ld
),
option
,
&
infoU
);
if
(
ret
!=
LDAP_SUCCESS
)
return
map_error
(
ret
);
if
(
infoU
.
ldapai_extensions
&&
!
(
infoW
->
ldapai_extensions
=
strarrayUtoW
(
infoU
.
ldapai_extensions
)))
return
WLDAP32_LDAP_NO_MEMORY
;
if
(
infoU
.
ldapai_vendor_name
&&
!
(
infoW
->
ldapai_vendor_name
=
strUtoW
(
infoU
.
ldapai_vendor_name
)))
{
ldap_memvfree
(
(
void
**
)
infoU
.
ldapai_extensions
);
return
WLDAP32_LDAP_NO_MEMORY
;
}
infoW
->
ldapai_vendor_version
=
infoU
.
ldapai_vendor_version
;
infoW
->
ldapai_extensions
=
strarrayUtoW
(
infoU
.
ldapai_extensions
);
if
(
infoU
.
ldapai_extensions
&&
!
infoW
->
ldapai_extensions
)
{
ret
=
WLDAP32_LDAP_NO_MEMORY
;
strarrayfreeU
(
infoU
.
ldapai_extensions
);
free
(
infoU
.
ldapai_vendor_name
)
;
return
WLDAP32_LDAP_NO_MEMORY
;
}
ldap_memvfree
(
(
void
**
)
infoU
.
ldapai_extensions
);
ldap_memfree
(
infoU
.
ldapai_vendor_name
);
infoW
->
ldapai_vendor_name
=
strUtoW
(
infoU
.
ldapai_vendor_name
);
if
(
infoU
.
ldapai_vendor_name
&&
!
infoW
->
ldapai_vendor_name
)
{
strarrayfreeU
(
infoU
.
ldapai_extensions
);
free
(
infoU
.
ldapai_vendor_name
);
strarrayfreeW
(
infoW
->
ldapai_extensions
);
return
WLDAP32_LDAP_NO_MEMORY
;
}
return
ret
;
infoW
->
ldapai_api_version
=
infoU
.
ldapai_api_version
;
infoW
->
ldapai_protocol_version
=
infoU
.
ldapai_protocol_version
;
infoW
->
ldapai_vendor_version
=
infoU
.
ldapai_vendor_version
;
return
WLDAP32_LDAP_SUCCESS
;
}
case
WLDAP32_LDAP_OPT_DEREF
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment