[svn:parrot] r37461 - trunk/src/pmc
chromatic at svn.parrot.org
chromatic at svn.parrot.org
Sun Mar 15 21:35:58 UTC 2009
Author: chromatic
Date: Sun Mar 15 21:35:58 2009
New Revision: 37461
URL: https://trac.parrot.org/parrot/changeset/37461
Log:
[PMC] Rearranged code in backtrace() method so that the annotations PMC is
never used (or passed elsewhere!) as an uninitialized pointer.
Modified:
trunk/src/pmc/exception.pmc
Modified: trunk/src/pmc/exception.pmc
==============================================================================
--- trunk/src/pmc/exception.pmc Sun Mar 15 20:44:48 2009 (r37460)
+++ trunk/src/pmc/exception.pmc Sun Mar 15 21:35:58 2009 (r37461)
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2008, Parrot Foundation.
+Copyright (C) 2001-2009, Parrot Foundation.
$Id$
=head1 NAME
@@ -753,35 +753,43 @@
/* Get starting context, then loop over them. */
GET_ATTR_resume(interp, SELF, resume);
if (!PMC_IS_NULL(resume)) {
- Parrot_cont *cont = PMC_cont(resume);
+ Parrot_cont *cont = PMC_cont(resume);
Parrot_Context *cur_ctx = cont->to_ctx;
+
while (cur_ctx) {
- PMC *frame = pmc_new(interp, enum_class_Hash);
- PMC *annotations;
+ PMC *frame = pmc_new(interp, enum_class_Hash);
+ PMC *annotations = NULL;
Parrot_sub *sub;
/* Get sub and put it in the hash. */
PMC *sub_pmc = cur_ctx->current_sub;
- if (sub_pmc == NULL)
+
+ if (!sub_pmc)
sub_pmc = PMCNULL;
+
VTABLE_set_pmc_keyed_str(interp, frame, CONST_STRING(interp, "sub"), sub_pmc);
/* Look up any annotations and put them in the hash. */
- if (!PMC_IS_NULL(sub_pmc) && sub_pmc->vtable->base_type == enum_class_Sub) {
+ if (!PMC_IS_NULL(sub_pmc)
+ && sub_pmc->vtable->base_type == enum_class_Sub) {
PMC_get_sub(interp, sub_pmc, sub);
if (sub->seg->annotations) {
PackFile_ByteCode *seg = sub->seg;
- opcode_t *pc = cur_ctx == cont->to_ctx ?
- cont->address : cur_ctx->current_pc;
- annotations = PackFile_Annotations_lookup(interp, seg->annotations,
- pc - seg->base.data, NULL);
+ opcode_t *pc = cur_ctx == cont->to_ctx
+ ? cont->address
+ : cur_ctx->current_pc;
+
+ annotations = PackFile_Annotations_lookup(interp,
+ seg->annotations, pc - seg->base.data,
+ NULL);
}
}
- else {
+
+ if (!annotations)
annotations = pmc_new(interp, enum_class_Hash);
- }
+
VTABLE_set_pmc_keyed_str(interp, frame, CONST_STRING(interp, "annotations"), annotations);
/* Push frame and go to next caller. */
More information about the parrot-commits
mailing list