This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
op.c: Simplify expression.
authorKarl Williamson <khw@cpan.org>
Sun, 27 Oct 2019 15:55:10 +0000 (09:55 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 7 Nov 2019 04:22:24 +0000 (21:22 -0700)
This also makes sure 'struct_size' has the correct value in it for any
future uses.

op.c

diff --git a/op.c b/op.c
index 712b00d..e08b769 100644 (file)
--- a/op.c
+++ b/op.c
@@ -7097,9 +7097,8 @@ S_pmtrans(pTHX_ OP *o, OP *expr, OP *repl)
                 * store excess replacement chars at end of main table.
                 */
 
-                struct_size += excess;
-                tbl = (OPtrans_map*)PerlMemShared_realloc(tbl,
-                            struct_size + excess * sizeof(short));
+                struct_size += excess * sizeof(short);
+                tbl = (OPtrans_map*)PerlMemShared_realloc(tbl, struct_size);
                 tbl->size += excess;
                 cPVOPo->op_pv = (char*)tbl;