This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Memory-management macros evaluate their arguments multiple times
authorFather Chrysostomos <sprout@cpan.org>
Mon, 25 Oct 2010 01:39:25 +0000 (18:39 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 25 Oct 2010 01:39:25 +0000 (18:39 -0700)
hv.c

diff --git a/hv.c b/hv.c
index 89941d8..0b347f5 100644 (file)
--- a/hv.c
+++ b/hv.c
@@ -2075,7 +2075,8 @@ Perl_hv_name_add(pTHX_ HV *hv, const char *name, U32 len)
            if (
             HEK_LEN(*hekp) == (I32)len && memEQ(HEK_KEY(*hekp), name, len)
            ) return;
-       Renewc(aux->xhv_name, ++aux->xhv_name_count, HEK *, HEK);
+       aux->xhv_name_count++;
+       Renewc(aux->xhv_name, aux->xhv_name_count, HEK *, HEK);
        ((HEK **)aux->xhv_name)[count] = share_hek(name, len, hash);
     }
     else {
@@ -2084,7 +2085,8 @@ Perl_hv_name_add(pTHX_ HV *hv, const char *name, U32 len)
            HEK_LEN(existing_name) == (I32)len
         && memEQ(HEK_KEY(existing_name), name, len)
        ) return;
-       Newxc(aux->xhv_name, aux->xhv_name_count = 2, HEK *, HEK);
+       Newxc(aux->xhv_name, 2, HEK *, HEK);
+       aux->xhv_name_count = 2;
        *(HEK **)aux->xhv_name = existing_name;
        ((HEK **)aux->xhv_name)[1] = share_hek(name, len, hash);
     }