https://git.reactos.org/?p=reactos.git;a=commitdiff;h=15c29d0798a464f021230…
commit 15c29d0798a464f0212301fa96a9bc6e34773998
Author: Serge Gautherie <reactos-git_serge_171003(a)gautherie.fr>
AuthorDate: Fri Jun 8 16:24:05 2018 +0200
Commit: Colin Finck <colin(a)reactos.org>
CommitDate: Sun Jun 17 12:16:08 2018 +0200
[NETAPI32_APITEST] Fix a NULL dereference of pInfo
With DPH enabled,
{{
Unhandled exception
ExceptionCode: c0000005
Faulting Address: 0
...
modules/rostests/apitests/netapi32/DsRoleGetPrimaryDomainInformation.c:23
(func_DsRoleGetPrimaryDomainInformation)
...
}}
---
.../apitests/netapi32/DsRoleGetPrimaryDomainInformation.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/modules/rostests/apitests/netapi32/DsRoleGetPrimaryDomainInformation.c
b/modules/rostests/apitests/netapi32/DsRoleGetPrimaryDomainInformation.c
index 4882d35620..900ecd46aa 100644
--- a/modules/rostests/apitests/netapi32/DsRoleGetPrimaryDomainInformation.c
+++ b/modules/rostests/apitests/netapi32/DsRoleGetPrimaryDomainInformation.c
@@ -3,6 +3,7 @@
* LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Tests for DsRoleGetPrimaryDomainInformation
* COPYRIGHT: Copyright 2017 Colin Finck (colin(a)reactos.org)
+ * Copyright 2018 Serge Gautherie
<reactos-git_serge_171003(a)gautherie.fr>
*/
#include <apitest.h>
@@ -20,8 +21,12 @@ START_TEST(DsRoleGetPrimaryDomainInformation)
// Get information about the domain membership of this computer.
dwErrorCode = DsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic,
(PBYTE*)&pInfo);
ok(dwErrorCode == ERROR_SUCCESS, "DsRoleGetPrimaryDomainInformation returns
%lu!\n", dwErrorCode);
- ok(pInfo->MachineRole >= DsRole_RoleStandaloneWorkstation &&
pInfo->MachineRole <= DsRole_RolePrimaryDomainController,
"pInfo->MachineRole is %u!\n", pInfo->MachineRole);
+ if (pInfo == NULL)
+ {
+ skip("pInfo is NULL\n");
+ return;
+ }
- if (pInfo)
- DsRoleFreeMemory(pInfo);
+ ok(pInfo->MachineRole >= DsRole_RoleStandaloneWorkstation &&
pInfo->MachineRole <= DsRole_RolePrimaryDomainController,
"pInfo->MachineRole is %u!\n", pInfo->MachineRole);
+ DsRoleFreeMemory(pInfo);
}