Skip to content

Commit 96c0b32

Browse files
committed
Storable: protect from empty retrieve_vstring
empty sv detected by coverity
1 parent 7480434 commit 96c0b32

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

dist/Storable/Storable.xs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4543,7 +4543,7 @@ static SV *retrieve_blessed(pTHX_ stcxt_t *cxt, const char *cname)
45434543
* Retrieve object and bless it.
45444544
*/
45454545

4546-
sv = retrieve(aTHX_ cxt, classname); /* First SV which is SEEN will be blessed */
4546+
sv = retrieve(aTHX_ cxt, classname); /* First SV which is SEEN will be blessed */
45474547
if (malloced_classname)
45484548
Safefree(malloced_classname);
45494549

@@ -5537,9 +5537,9 @@ static SV *retrieve_vstring(pTHX_ stcxt_t *cxt, const char *cname)
55375537
TRACEME(("retrieve_vstring (#%d), len = %d", (int)cxt->tagnum, len));
55385538

55395539
READ(s, len);
5540-
55415540
sv = retrieve(aTHX_ cxt, cname);
5542-
5541+
if (!sv)
5542+
return (SV *) 0; /* Failed */
55435543
sv_magic(sv,NULL,PERL_MAGIC_vstring,s,len);
55445544
/* 5.10.0 and earlier seem to need this */
55455545
SvRMAGICAL_on(sv);
@@ -5572,7 +5572,8 @@ static SV *retrieve_lvstring(pTHX_ stcxt_t *cxt, const char *cname)
55725572
SAFEPVREAD(s, len, s);
55735573

55745574
sv = retrieve(aTHX_ cxt, cname);
5575-
5575+
if (!sv)
5576+
return (SV *) 0; /* Failed */
55765577
sv_magic(sv,NULL,PERL_MAGIC_vstring,s,len);
55775578
/* 5.10.0 and earlier seem to need this */
55785579
SvRMAGICAL_on(sv);
@@ -6445,7 +6446,7 @@ static SV *old_retrieve_array(pTHX_ stcxt_t *cxt, const char *cname)
64456446
if (c != SX_ITEM)
64466447
(void) retrieve_other(aTHX_ cxt, 0);/* Will croak out */
64476448
TRACEME(("(#%d) item", (int)i));
6448-
sv = retrieve(aTHX_ cxt, 0); /* Retrieve item */
6449+
sv = retrieve(aTHX_ cxt, 0); /* Retrieve item */
64496450
if (!sv)
64506451
return (SV *) 0;
64516452
if (av_store(av, i, sv) == 0)

0 commit comments

Comments
 (0)