src/acpi/acpigen: Add NULL pointer check

Add NULL pointer check in acpigen_emit_namestring
to avoid segmentation fault.

Change-Id: I3d01d28e74f202278b5a5a96d2edd45c66f10883
Signed-off-by: Ronak Kanabar <ronak.kanabar@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/48148
Reviewed-by: Subrata Banik <subrata.banik@intel.com>
Reviewed-by: Maulik V Vaghela <maulik.v.vaghela@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Ronak Kanabar 2020-11-30 15:40:51 +05:30 committed by Subrata Banik
parent ab0d85c987
commit 7c0f007cf5
1 changed files with 4 additions and 0 deletions

View File

@ -291,6 +291,10 @@ void acpigen_emit_namestring(const char *namepath)
int dotcount = 0, i; int dotcount = 0, i;
int dotpos = 0; int dotpos = 0;
/* Check for NULL pointer */
if (!namepath)
return;
/* We can start with a '\'. */ /* We can start with a '\'. */
if (namepath[0] == '\\') { if (namepath[0] == '\\') {
acpigen_emit_byte('\\'); acpigen_emit_byte('\\');