]> granicus.if.org Git - onig/commitdiff
regexec: check xrealloc return value
authorRuslan Kuprieiev <kupruser@gmail.com>
Thu, 15 Jun 2017 20:07:51 +0000 (23:07 +0300)
committerRuslan Kuprieiev <kupruser@gmail.com>
Sat, 24 Jun 2017 01:54:25 +0000 (04:54 +0300)
"Unchecked return value of 'xrealloc' that is later used to in
pointer arithmetic and can lead to undefined behaviour."

Id: 16

Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
src/regexec.c

index c0626efd43b6ed410bb8dcdc86fc4e477b60c74f..09b3a395a11ca934705514642bf72a5fb2bd93e5 100644 (file)
@@ -277,7 +277,9 @@ onig_region_copy(OnigRegion* to, OnigRegion* from)
   }
   else if (to->allocated < from->num_regs) {
     to->beg = (int* )xrealloc(to->beg, RREGC_SIZE);
+    if (IS_NULL(to->beg)) return;
     to->end = (int* )xrealloc(to->end, RREGC_SIZE);
+    if (IS_NULL(to->end)) return;
     to->allocated = from->num_regs;
   }