/*
* newSV did not upgrade to SVt_PV so the scalar is undefined.
* To make it defined with an empty length, upgrade it now...
+ * Don't upgrade to a PV if the original type contains more
+ * information than a scalar.
*/
- sv_upgrade(sv, SVt_PV);
+ if (SvTYPE(sv) <= SVt_PV) {
+ sv_upgrade(sv, SVt_PV);
+ }
SvGROW(sv, 1);
*SvEND(sv) = '\0'; /* Ensure it's null terminated anyway */
TRACEME(("ok (retrieve_scalar empty at 0x%"UVxf")", PTR2UV(sv)));
use Storable qw(dclone);
-print "1..9\n";
+print "1..10\n";
$a = 'toto';
$b = \$a;
print "not " unless $$cloned{''}[0] == \$$cloned{a};
print "ok 9\n";
+# [ID 20020221.007] SEGV in Storable with empty string scalar object
+package TestString;
+sub new {
+ my ($type, $string) = @_;
+ return bless(\$string, $type);
+}
+package main;
+my $empty_string_obj = TestString->new('');
+my $clone = dclone($empty_string_obj);
+# If still here after the dclone the fix (#17543) worked.
+print ref $clone eq ref $empty_string_obj &&
+ $$clone eq $$empty_string_obj &&
+ $$clone eq '' ? "ok 10\n" : "not ok 10\n";
+