summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
17f8c9e)
Since TianoCore EDK2 commit
d65f2cea36d1 ("ShellPkg/CommandLib: Locate
proper UnicodeCollation instance") in edk2 the UEFI Shell crashes if EFI
variable PlatformLang is not defined due to dereferencing gUnicodeCollation
gUnicodeCollation (= NULL) in ShellCommandRegisterCommandName().
Furthermore CommandInit() is leaking PlatformLang if
gUnicodeCollation != NULL.
Close the memory leak and use the first UnicodeCollation instance if
PlatfomLang is not defined.
Fixes: d65f2cea36d1 ("ShellPkg/CommandLib: Locate proper UnicodeCollation
instance")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
EFI_STATUS Status;\r
CHAR8 *PlatformLang;\r
\r
EFI_STATUS Status;\r
CHAR8 *PlatformLang;\r
\r
- GetEfiGlobalVariable2 (EFI_PLATFORM_LANG_VARIABLE_NAME, (VOID**)&PlatformLang, NULL);\r
- if (PlatformLang == NULL) {\r
- return EFI_UNSUPPORTED;\r
- }\r
-\r
if (gUnicodeCollation == NULL) {\r
if (gUnicodeCollation == NULL) {\r
+\r
+ GetEfiGlobalVariable2 (EFI_PLATFORM_LANG_VARIABLE_NAME, (VOID**)&PlatformLang, NULL);\r
+\r
Status = gBS->LocateHandleBuffer (\r
ByProtocol,\r
&gEfiUnicodeCollation2ProtocolGuid,\r
Status = gBS->LocateHandleBuffer (\r
ByProtocol,\r
&gEfiUnicodeCollation2ProtocolGuid,\r
+ //\r
+ // Without clue provided use the first Unicode Collation2 protocol.\r
+ //\r
+ if (PlatformLang == NULL) {\r
+ gUnicodeCollation = Uc;\r
+ break;\r
+ }\r
+\r
//\r
// Find the best matching matching language from the supported languages\r
// of Unicode Collation2 protocol.\r
//\r
// Find the best matching matching language from the supported languages\r
// of Unicode Collation2 protocol.\r
if (Handles != NULL) {\r
FreePool (Handles);\r
}\r
if (Handles != NULL) {\r
FreePool (Handles);\r
}\r
- FreePool (PlatformLang);\r
+ if (PlatformLang != NULL) {\r
+ FreePool (PlatformLang);\r
+ }\r
}\r
\r
return (gUnicodeCollation == NULL) ? EFI_UNSUPPORTED : EFI_SUCCESS;\r
}\r
\r
return (gUnicodeCollation == NULL) ? EFI_UNSUPPORTED : EFI_SUCCESS;\r