MdeModulePkg/RegularExpressionDxe: Add null pointer check

There are five check not necessary in logic ,just for pass static
analysis. More detail please refer to comment in code.
And the rest changes are all accepted by owner, they are reasonable.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dongao Guo <dongao.guo@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Dongao Guo
2018-10-11 14:57:03 +08:00
committed by Liming Gao
parent df8be9e50f
commit 3948c510ed
2 changed files with 34 additions and 5 deletions

View File

@@ -3546,8 +3546,12 @@ expand_case_fold_string_alt(int item_num, OnigCaseFoldCodeItem items[], UChar *p
if (IS_NULL(an)) {
goto mem_err2;
}
if (items[i].byte_len != slen) {
//The NULL pointer check is not necessary. It is added just for pass static
//analysis. When condition "items[i].byte_len != slen" is true, "varlen = 1"
//in line 3503 will be reached ,so that "if (IS_NULL(var_anode)) return ONIGERR_MEMORY"
//in line 3510 will be executed, so the null pointer has been checked before
//deferenced in line 3584.
if (items[i].byte_len != slen && IS_NOT_NULL(var_anode)) {
Node *rem;
UChar *q = p + items[i].byte_len;