diff options
author | Peter Zhu <[email protected]> | 2023-06-29 16:31:35 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2023-06-30 09:13:31 -0400 |
commit | 58386814a7c7275f66ffa111175fca2fe307a1b5 (patch) | |
tree | 56bfd1daec3a6d83dfda64b569de1b9fbbb4d23c /regexec.c | |
parent | 37a893d12915b8860f6880d6a0c2859e096ab4ff (diff) |
Don't check for null pointer in calls to free
According to the C99 specification section 7.20.3.2 paragraph 2:
> If ptr is a null pointer, no action occurs.
So we do not need to check that the pointer is a null pointer.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8004
Diffstat (limited to 'regexec.c')
-rw-r--r-- | regexec.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -886,8 +886,8 @@ onig_region_free(OnigRegion* r, int free_self) { if (r) { if (r->allocated > 0) { - if (r->beg) xfree(r->beg); - if (r->end) xfree(r->end); + xfree(r->beg); + xfree(r->end); r->allocated = 0; } #ifdef USE_CAPTURE_HISTORY @@ -965,8 +965,8 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) (msa).match_cache_buf = (uint8_t*)NULL;\ } while(0) #define MATCH_ARG_FREE_MATCH_CACHE(msa) do {\ - if ((msa).cache_opcodes != NULL) xfree((msa).cache_opcodes);\ - if ((msa).match_cache_buf != NULL) xfree((msa).match_cache_buf);\ + xfree((msa).cache_opcodes);\ + xfree((msa).match_cache_buf);\ (msa).cache_opcodes = (OnigCacheOpcode*)NULL;\ (msa).match_cache_buf = (uint8_t*)NULL;\ } while(0) @@ -1031,15 +1031,15 @@ onig_region_copy(OnigRegion* to, const OnigRegion* from) } while(0) # define MATCH_ARG_FREE(msa) do {\ - if ((msa).stack_p) xfree((msa).stack_p);\ + xfree((msa).stack_p);\ if ((msa).state_check_buff_size >= STATE_CHECK_BUFF_MALLOC_THRESHOLD_SIZE) { \ - if ((msa).state_check_buff) xfree((msa).state_check_buff);\ + xfree((msa).state_check_buff);\ }\ MATCH_ARG_FREE_MATCH_CACHE(msa);\ } while(0) #else /* USE_COMBINATION_EXPLOSION_CHECK */ # define MATCH_ARG_FREE(msa) do {\ - if ((msa).stack_p) xfree((msa).stack_p);\ + xfree((msa).stack_p);\ MATCH_ARG_FREE_MATCH_CACHE(msa);\ } while (0) #endif /* USE_COMBINATION_EXPLOSION_CHECK */ @@ -1151,7 +1151,7 @@ stack_double(OnigStackType** arg_stk_base, OnigStackType** arg_stk_end, int r = stack_double(&stk_base, &stk_end, &stk, stk_alloc, msa);\ if (r != 0) {\ STACK_SAVE;\ - if (xmalloc_base) xfree(xmalloc_base);\ + xfree(xmalloc_base);\ return r;\ }\ }\ @@ -4044,24 +4044,24 @@ match_at(regex_t* reg, const UChar* str, const UChar* end, finish: STACK_SAVE; - if (xmalloc_base) xfree(xmalloc_base); + xfree(xmalloc_base); return best_len; #ifdef ONIG_DEBUG stack_error: STACK_SAVE; - if (xmalloc_base) xfree(xmalloc_base); + xfree(xmalloc_base); return ONIGERR_STACK_BUG; #endif bytecode_error: STACK_SAVE; - if (xmalloc_base) xfree(xmalloc_base); + xfree(xmalloc_base); return ONIGERR_UNDEFINED_BYTECODE; unexpected_bytecode_error: STACK_SAVE; - if (xmalloc_base) xfree(xmalloc_base); + xfree(xmalloc_base); return ONIGERR_UNEXPECTED_BYTECODE; } |