mirror of https://github.com/acidanthera/audk.git
BaseTools/C/Common: Fix potential null pointer dereference
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
46cced287e
commit
66329d53bd
|
@ -72,6 +72,9 @@ Returns:
|
||||||
CHAR8 *Token;
|
CHAR8 *Token;
|
||||||
|
|
||||||
Token = malloc (TokenEnd - TokenStart + 1);
|
Token = malloc (TokenEnd - TokenStart + 1);
|
||||||
|
if (Token == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
memcpy (Token, &FileBuffer[TokenStart], TokenEnd - TokenStart);
|
memcpy (Token, &FileBuffer[TokenStart], TokenEnd - TokenStart);
|
||||||
Token[TokenEnd - TokenStart] = 0;
|
Token[TokenEnd - TokenStart] = 0;
|
||||||
switch (TokenIndex) {
|
switch (TokenIndex) {
|
||||||
|
@ -333,6 +336,10 @@ Returns:
|
||||||
Value = End + 1;
|
Value = End + 1;
|
||||||
}
|
}
|
||||||
Buffer = malloc(*Size);
|
Buffer = malloc(*Size);
|
||||||
|
if (Buffer == NULL) {
|
||||||
|
*Size = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
Value = &PcdList[Index].Value[1];
|
Value = &PcdList[Index].Value[1];
|
||||||
for (*Size = 0, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16); Value != End; *Size = *Size + 1, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16)) {
|
for (*Size = 0, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16); Value != End; *Size = *Size + 1, Buffer[*Size] = (UINT8) strtoul(Value, &End, 16)) {
|
||||||
Value = End + 1;
|
Value = End + 1;
|
||||||
|
|
Loading…
Reference in New Issue