MdeModulePkg: Add NULL pointer check for RegularExpressionDxe.

Refine code by adding NULL pointer check to avoid potential NULL pointer dereferenced.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Samer El-Haj-Mahmoud <elhaj@hpe.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19271 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Qiu Shumin
2015-12-15 08:40:55 +00:00
committed by shenshushi
parent 00d1c2a35e
commit b0c2b79738
7 changed files with 50 additions and 4 deletions

View File

@@ -243,7 +243,9 @@ onig_region_new(void)
OnigRegion* r;
r = (OnigRegion* )xmalloc(sizeof(OnigRegion));
onig_region_init(r);
if (r != NULL) {
onig_region_init(r);
}
return r;
}
@@ -284,6 +286,10 @@ onig_region_copy(OnigRegion* to, OnigRegion* from)
to->allocated = from->num_regs;
}
if (to->beg == NULL || to->end == NULL) {
return;
}
for (i = 0; i < from->num_regs; i++) {
to->beg[i] = from->beg[i];
to->end[i] = from->end[i];