From f0119d260331bceb7fc6826fee34230ac2b22851 Mon Sep 17 00:00:00 2001 From: jnthn Date: Sat, 8 Oct 2011 23:28:27 +0200 Subject: [PATCH] Ensure we don't produce something that will cause segfaults when unboxing to a native str. --- src/6model/reprs/P6opaque.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/6model/reprs/P6opaque.c b/src/6model/reprs/P6opaque.c index 82f73d6ffa..ef852ede9d 100644 --- a/src/6model/reprs/P6opaque.c +++ b/src/6model/reprs/P6opaque.c @@ -695,7 +695,10 @@ static STRING * get_str(PARROT_INTERP, PMC *obj) { Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION, "Cannot unbox type object to a native string"); } - return get_str_at_offset(instance, repr_data->unbox_str_offset); + else { + STRING *s = get_str_at_offset(instance, repr_data->unbox_str_offset); + return s ? s : STRINGNULL; + } } else { Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,