summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
diff options
context:
space:
mode:
authorAaron Pop <aaronpop@microsoft.com>2025-10-22 21:33:02 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2026-08-05 06:07:16 +0300
commitdfd0edeb4e71f01f83cf9aa53285db4f14e5487d (patch)
treeeadf849879e2616b236bb70f85721a25e621d035 /MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
parent699382e3429a4ecd3ccd58d333f413e14bb10edc (diff)
downloadedk2-dfd0edeb4e71f01f83cf9aa53285db4f14e5487d.tar.xz
MdeModulePkg: Fix missing NULL tests
https://github.com/github/codeql/blob/codeql-cli-2.7.3/cpp/ql/src/Critical/MissingNullTest.qhelp For items which allocate memory, or get a pointer from another structure, it is important to validate that the pointers are not null before they are dereferenced. Signed-off-by: Aaron Pop <aaronpop@microsoft.com>
Diffstat (limited to 'MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c')
-rw-r--r--MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
index 68c2e35791..18415c056e 100644
--- a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
+++ b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
@@ -610,7 +610,12 @@ DumpSmiHandler (
Print (L">\n");
ImageStruct = GetImageFromRef ((UINTN)SmiHandlerStruct->ImageRef);
- NameString = GetDriverNameString (ImageStruct);
+ if (ImageStruct != NULL) {
+ NameString = GetDriverNameString (ImageStruct);
+ } else {
+ NameString = "\0";
+ }
+
Print (L" <Module RefId=\"0x%x\" Name=\"%a\">\n", SmiHandlerStruct->ImageRef, NameString);
if ((ImageStruct != NULL) && (ImageStruct->PdbStringOffset != 0)) {
Print (L" <Pdb>%a</Pdb>\n", (UINT8 *)ImageStruct + ImageStruct->PdbStringOffset);