]> granicus.if.org Git - onig/commitdiff
PR #62 check malloc return value
authorK.Kosako <kosako@sofnec.co.jp>
Mon, 26 Jun 2017 02:21:25 +0000 (11:21 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Mon, 26 Jun 2017 02:21:25 +0000 (11:21 +0900)
src/regparse.c

index 7f07bb6bc72c26b4ce9aa55652c434ff8004fcdf..24e0510d08a4f73d710588771a8e5ccf5c9cd263 100644 (file)
@@ -1020,13 +1020,14 @@ scan_env_add_mem_entry(ScanEnv* env)
       if (IS_NULL(env->mem_env_dynamic)) {
         alloc = INIT_SCANENV_MEMENV_ALLOC_SIZE;
         p = (MemEnv* )xmalloc(sizeof(MemEnv) * alloc);
+        CHECK_NULL_RETURN_MEMERR(p);
         xmemcpy(p, env->mem_env_static, sizeof(env->mem_env_static));
       }
       else {
         alloc = env->mem_alloc * 2;
         p = (MemEnv* )xrealloc(env->mem_env_dynamic, sizeof(MemEnv) * alloc);
+        CHECK_NULL_RETURN_MEMERR(p);
       }
-      CHECK_NULL_RETURN_MEMERR(p);
 
       for (i = env->num_mem + 1; i < alloc; i++) {
         p[i].node = NULL_NODE;