diff options
-rw-r--r-- | doio.c | 3 | ||||
-rw-r--r-- | t/io/shm.t | 12 |
2 files changed, 13 insertions, 2 deletions
@@ -2283,9 +2283,10 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp) if (optype == OP_SHMREAD) { char *mbuf; /* suppress warning when reading into undef var (tchrist 3/Mar/00) */ + SvGETMAGIC(mstr); + SvUPGRADE(mstr, SVt_PV); if (! SvOK(mstr)) sv_setpvs(mstr, ""); - SvUPGRADE(mstr, SVt_PV); SvPOK_only(mstr); mbuf = SvGROW(mstr, (STRLEN)msize+1); diff --git a/t/io/shm.t b/t/io/shm.t index 0ba566b1d4..4a8941ec75 100644 --- a/t/io/shm.t +++ b/t/io/shm.t @@ -55,7 +55,7 @@ if (not defined $key) { } } else { - plan(tests => 13); + plan(tests => 15); pass('acquired shared mem'); } @@ -80,3 +80,13 @@ shmwrite $key, $int, 0, 1; shmread $key, $number, 0, 1; is("$number", $int, qq{"\$id" eq "$int"}); cmp_ok($number + 0, '==', $int, "\$id + 0 == $int"); + +my ($fetch, $store) = (0, 0); +{ package Counted; + sub TIESCALAR { bless [undef] } + sub FETCH { ++$fetch; $_[0][0] } + sub STORE { ++$store; $_[0][0] = $_[1] } } +tie $ct, 'Counted'; +shmread $key, $ct, 0, 1; +is($fetch, 1, "shmread FETCH once"); +is($store, 1, "shmread STORE once"); |