diff options
author | Karl Williamson <khw@cpan.org> | 2014-09-16 17:19:52 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-09-29 11:07:40 -0600 |
commit | 81a9a93bd8cf15be6db1942f8e44c590ecbace15 (patch) | |
tree | 5decf7144b35fe88cf01f19c256eaf4f7a0fa506 /regcomp.c | |
parent | 9990d5ab621b83dea3adb80c343aff125fe9764b (diff) | |
download | perl-81a9a93bd8cf15be6db1942f8e44c590ecbace15.tar.gz |
regcomp.c: Add assertions
This changes from assuming that certain things are constant to using a
variable instead, and then asserting that the variable matches the
constant.
Diffstat (limited to 'regcomp.c')
-rw-r--r-- | regcomp.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -15425,6 +15425,8 @@ S_regnode_guts(pTHX_ RExC_state_t *pRExC_state, const U8 op, const STRLEN extra_ PERL_ARGS_ASSERT_REGNODE_GUTS; + assert(extra_size >= regarglen[op]); + if (SIZE_ONLY) { SIZE_ALIGN(RExC_size); RExC_size += 1 + extra_size; @@ -15460,10 +15462,12 @@ S_regnode_guts(pTHX_ RExC_state_t *pRExC_state, const U8 op, const STRLEN extra_ STATIC regnode * /* Location. */ S_reg_node(pTHX_ RExC_state_t *pRExC_state, U8 op) { - regnode * const ret = regnode_guts(pRExC_state, op, 0, "reg_node"); + regnode * const ret = regnode_guts(pRExC_state, op, regarglen[op], "reg_node"); PERL_ARGS_ASSERT_REG_NODE; + assert(regarglen[op] == 0); + if (PASS2) { regnode *ptr = ret; FILL_ADVANCE_NODE(ptr, op); @@ -15478,10 +15482,12 @@ S_reg_node(pTHX_ RExC_state_t *pRExC_state, U8 op) STATIC regnode * /* Location. */ S_reganode(pTHX_ RExC_state_t *pRExC_state, U8 op, U32 arg) { - regnode * const ret = regnode_guts(pRExC_state, op, 1, "reganode"); + regnode * const ret = regnode_guts(pRExC_state, op, regarglen[op], "reganode"); PERL_ARGS_ASSERT_REGANODE; + assert(regarglen[op] == 1); + if (PASS2) { regnode *ptr = ret; FILL_ADVANCE_NODE_ARG(ptr, op, arg); |