diff options
author | Hao Wu <hao.a.wu@intel.com> | 2018-01-03 19:30:36 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2018-01-15 10:42:17 +0800 |
commit | 66329d53bde5febe55cb1e8d3352ff94d3773277 (patch) | |
tree | d166ef154718507bc283d4ef9399df22209d9393 | |
parent | 46cced287e3a01c19929c4a92bbb713c9c999842 (diff) | |
download | edk2-66329d53bde5febe55cb1e8d3352ff94d3773277.zip edk2-66329d53bde5febe55cb1e8d3352ff94d3773277.tar.gz edk2-66329d53bde5febe55cb1e8d3352ff94d3773277.tar.bz2 |
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>
-rw-r--r-- | BaseTools/Source/C/Common/PcdValueCommon.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/BaseTools/Source/C/Common/PcdValueCommon.c b/BaseTools/Source/C/Common/PcdValueCommon.c index 348f148..32963e6 100644 --- a/BaseTools/Source/C/Common/PcdValueCommon.c +++ b/BaseTools/Source/C/Common/PcdValueCommon.c @@ -72,6 +72,9 @@ Returns: CHAR8 *Token;
Token = malloc (TokenEnd - TokenStart + 1);
+ if (Token == NULL) {
+ return;
+ }
memcpy (Token, &FileBuffer[TokenStart], TokenEnd - TokenStart);
Token[TokenEnd - TokenStart] = 0;
switch (TokenIndex) {
@@ -333,6 +336,10 @@ Returns: Value = End + 1;
}
Buffer = malloc(*Size);
+ if (Buffer == NULL) {
+ *Size = 0;
+ return NULL;
+ }
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)) {
Value = End + 1;
|