From 109fd094ea3ad0a7f92ed807cf3f0a3a08e06c25 Mon Sep 17 00:00:00 2001 From: Rafal Kupiec Date: Fri, 16 Feb 2024 19:05:53 +0100 Subject: [PATCH] Fix NULL pointer --- xtoskrnl/rtl/widestr.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xtoskrnl/rtl/widestr.c b/xtoskrnl/rtl/widestr.c index 9bc88eb..43ba75a 100644 --- a/xtoskrnl/rtl/widestr.c +++ b/xtoskrnl/rtl/widestr.c @@ -958,7 +958,7 @@ RtlpFormatWideStringArgumentSpecifier(IN PRTL_PRINT_CONTEXT Context, GuidArg = VA_ARG(*ArgumentList, PGUID); } - /* Make sure GUID is not NULL */ + /* Make sure a pointer to GUID is not NULL */ if(GuidArg != NULL) { /* Write formatted GUID string */ @@ -1143,8 +1143,12 @@ RtlpFormatWideStringArgumentSpecifier(IN PRTL_PRINT_CONTEXT Context, AnsiStrArg = VA_ARG(*ArgumentList, PANSI_STRING); } - /* Write formatted ANSI string value */ - Status = RtlpWriteWideStringStringValue(Context, &FormatProperties, AnsiStrArg->Buffer, AnsiStrArg->Length); + /* Make sure a pointer to ANSI_STRING is not NULL */ + if(AnsiStrArg != NULL) + { + /* Write formatted ANSI string value */ + Status = RtlpWriteWideStringStringValue(Context, &FormatProperties, AnsiStrArg->Buffer, AnsiStrArg->Length); + } } else if(FormatProperties.VariableType == UnicodeString) { @@ -1161,8 +1165,12 @@ RtlpFormatWideStringArgumentSpecifier(IN PRTL_PRINT_CONTEXT Context, UnicodeStrArg = VA_ARG(*ArgumentList, PUNICODE_STRING); } - /* Write formatted UNICODE string value */ - Status = RtlpWriteWideStringValue(Context, &FormatProperties, UnicodeStrArg->Buffer, UnicodeStrArg->Length); + /* Make sure a pointer to UNICODE_STRING is not NULL */ + if(UnicodeStrArg != NULL) + { + /* Write formatted UNICODE string value */ + Status = RtlpWriteWideStringValue(Context, &FormatProperties, UnicodeStrArg->Buffer, UnicodeStrArg->Length); + } } /* Cleanup ArgumentsCopy object */