From: Nicholas Clark Date: Sat, 14 Oct 2006 22:40:00 +0000 (+0000) Subject: Avoid undefined behaviour for -DPERL_MEM_LOG by not using a direct X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2eb97020013532fece8d6206100165c4e92a4350;p=p5sagit%2Fp5-mst-13.2.git Avoid undefined behaviour for -DPERL_MEM_LOG by not using a direct dereference of member of the structure being reallocated as part of the size calculation. (There may be other similar bugs). p4raw-id: //depot/perl@29016 --- diff --git a/regcomp.c b/regcomp.c index 89ce420..7661432 100644 --- a/regcomp.c +++ b/regcomp.c @@ -3629,10 +3629,11 @@ STATIC I32 S_add_data(RExC_state_t *pRExC_state, I32 n, const char *s) { if (RExC_rx->data) { + const U32 count = RExC_rx->data->count; Renewc(RExC_rx->data, - sizeof(*RExC_rx->data) + sizeof(void*) * (RExC_rx->data->count + n - 1), + sizeof(*RExC_rx->data) + sizeof(void*) * (count + n - 1), char, struct reg_data); - Renew(RExC_rx->data->what, RExC_rx->data->count + n, U8); + Renew(RExC_rx->data->what, count + n, U8); RExC_rx->data->count += n; } else {