Memory leak in the BootManager code


Konstantin Aladyshev
 

Hello!

I have a question about dynamic content generation in the form
EFI_HII_CONFIG_ACCESS_PROTOCOL.Callback() code.
Usually such content is generated with the help of labels on the
EFI_BROWSER_ACTION_FORM_OPEN action. Example is the BootManager form.

The thing that I want to discuss is that strings for the generated
elements are produced via the `HiiSetString(HiiHandle, 0, <Text>,
NULL)` calls.
But if we use 0 as the second argument, this would produce new string
packages every time we enter the BootManager form. Isn't it a memory
leak?

Example:
https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Library/BootManagerUiLib/BootManager.c

BootManagerCallback() calls UpdateBootManager() on each form open
which creates new strings via:
```
Token = HiiSetString (HiiHandle, 0, BootOption[Index].Description, NULL);
HelpToken = HiiSetString (HiiHandle, 0, HelpString, NULL);
```

Best regards,
Konstantin Aladyshev