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