Avoid undefined behaviour for -DPERL_MEM_LOG by not using a
authorNicholas Clark <nick@ccl4.org>
Sat, 14 Oct 2006 23:06:52 +0000 (23:06 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 14 Oct 2006 23:06:52 +0000 (23:06 +0000)
dereference of member of the structure being reallocated as part of
the size calculation. (This one was well hidden by macros)

p4raw-id: //depot/perl@29018

regcomp.c

index 7661432..86e6865 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1133,9 +1133,8 @@ is the recommended Unicode-aware way of saying
 
 #define TRIE_LIST_PUSH(state,fid,ns) STMT_START {               \
     if ( TRIE_LIST_CUR( state ) >=TRIE_LIST_LEN( state ) ) {    \
-       TRIE_LIST_LEN( state ) *= 2;                            \
-       Renew( trie->states[ state ].trans.list,                \
-              TRIE_LIST_LEN( state ), reg_trie_trans_le );     \
+       U32 ging = TRIE_LIST_LEN( state ) *= 2;                 \
+       Renew( trie->states[ state ].trans.list, ging, reg_trie_trans_le ); \
     }                                                           \
     TRIE_LIST_ITEM( state, TRIE_LIST_CUR( state ) ).forid = fid;     \
     TRIE_LIST_ITEM( state, TRIE_LIST_CUR( state ) ).newstate = ns;   \