diff --git a/winpr/libwinpr/crt/string.c b/winpr/libwinpr/crt/string.c index 4015108f5..2717ac06d 100644 --- a/winpr/libwinpr/crt/string.c +++ b/winpr/libwinpr/crt/string.c @@ -98,6 +98,9 @@ size_t _wcslen(const WCHAR* str) { WCHAR* p = (WCHAR*) str; + if (!p) + return 0; + while (*p) p++; diff --git a/winpr/libwinpr/sspi/NTLM/ntlm.c b/winpr/libwinpr/sspi/NTLM/ntlm.c index 11258adf7..adc0d0d79 100644 --- a/winpr/libwinpr/sspi/NTLM/ntlm.c +++ b/winpr/libwinpr/sspi/NTLM/ntlm.c @@ -63,6 +63,11 @@ void ntlm_SetContextWorkstation(NTLM_CONTEXT* context, char* Workstation) void ntlm_SetContextServicePrincipalNameW(NTLM_CONTEXT* context, LPWSTR ServicePrincipalName) { context->ServicePrincipalName.Length = _wcslen(ServicePrincipalName) * 2; + if (!ServicePrincipalName) + { + context->ServicePrincipalName.Buffer = NULL; + return; + } context->ServicePrincipalName.Buffer = (PWSTR) malloc(context->ServicePrincipalName.Length + 2); CopyMemory(context->ServicePrincipalName.Buffer, ServicePrincipalName, context->ServicePrincipalName.Length + 2); }