a82cae
From fecd3be8dbdb747b9cbf4cbb9299ce40faabc8e6 Mon Sep 17 00:00:00 2001
a82cae
From: John Lightsey <lightsey@debian.org>
a82cae
Date: Mon, 14 Nov 2016 11:56:15 +0100
a82cae
Subject: [PATCH] Fix Storable segfaults.
a82cae
a82cae
Fix a null pointed dereference segfault in storable when the
a82cae
retrieve_code logic was unable to read the string that contained
a82cae
the code.
a82cae
a82cae
Also fix several locations where retrieve_other was called with a
a82cae
null context pointer. This also resulted in a null pointer
a82cae
dereference.
a82cae
---
a82cae
 dist/Storable/Storable.xs | 10 +++++++---
a82cae
 1 file changed, 7 insertions(+), 3 deletions(-)
a82cae
a82cae
diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs
a82cae
index 053951c..caa489c 100644
a82cae
--- a/dist/Storable/Storable.xs
a82cae
+++ b/dist/Storable/Storable.xs
a82cae
@@ -5647,6 +5647,10 @@ static SV *retrieve_code(pTHX_ stcxt_t *cxt, const char *cname)
a82cae
 		CROAK(("Unexpected type %d in retrieve_code\n", type));
a82cae
 	}
a82cae
 
a82cae
+	if (!text) {
a82cae
+		CROAK(("Unable to retrieve code\n"));
a82cae
+	}
a82cae
+
a82cae
 	/*
a82cae
 	 * prepend "sub " to the source
a82cae
 	 */
a82cae
@@ -5767,7 +5771,7 @@ static SV *old_retrieve_array(pTHX_ stcxt_t *cxt, const char *cname)
a82cae
 			continue;			/* av_extend() already filled us with undef */
a82cae
 		}
a82cae
 		if (c != SX_ITEM)
a82cae
-			(void) retrieve_other(aTHX_ (stcxt_t *) 0, 0);	/* Will croak out */
a82cae
+			(void) retrieve_other(aTHX_ cxt, 0);	/* Will croak out */
a82cae
 		TRACEME(("(#%d) item", i));
a82cae
 		sv = retrieve(aTHX_ cxt, 0);						/* Retrieve item */
a82cae
 		if (!sv)
a82cae
@@ -5844,7 +5848,7 @@ static SV *old_retrieve_hash(pTHX_ stcxt_t *cxt, const char *cname)
a82cae
 			if (!sv)
a82cae
 				return (SV *) 0;
a82cae
 		} else
a82cae
-			(void) retrieve_other(aTHX_ (stcxt_t *) 0, 0);	/* Will croak out */
a82cae
+			(void) retrieve_other(aTHX_ cxt, 0);	/* Will croak out */
a82cae
 
a82cae
 		/*
a82cae
 		 * Get key.
a82cae
@@ -5855,7 +5859,7 @@ static SV *old_retrieve_hash(pTHX_ stcxt_t *cxt, const char *cname)
a82cae
 
a82cae
 		GETMARK(c);
a82cae
 		if (c != SX_KEY)
a82cae
-			(void) retrieve_other(aTHX_ (stcxt_t *) 0, 0);	/* Will croak out */
a82cae
+			(void) retrieve_other(aTHX_ cxt, 0);	/* Will croak out */
a82cae
 		RLEN(size);						/* Get key size */
a82cae
 		KBUFCHK((STRLEN)size);					/* Grow hash key read pool if needed */
a82cae
 		if (size)
a82cae
-- 
a82cae
2.10.2
a82cae