Skip to content
This repository
Browse code

Don't use variables named 'pmc'

Parrot's SELF variables are named that.  The shadowing caused the wrong values
to be set in the wrong places, eventually causing a PMC to be treated as a
PerlInterpreter; segfault ensued.
commit 5fa07ce5e66bfd9846b8d5c7a450dbc87b90640d 1 parent 28e07ac
Stefan O'Rear sorear authored

Showing 2 changed files with 11 additions and 11 deletions. Show diff stats Hide diff stats

  1. +6 6 src/pmc/bkmarshal.c
  2. +5 5 src/pmc/p5interpreter.pmc
12 src/pmc/bkmarshal.c
@@ -126,16 +126,16 @@ PARROT_CANNOT_RETURN_NULL
126 126 PMC *
127 127 blizkost_wrap_sv(PARROT_INTERP, PMC *p5i, SV *sv) {
128 128 PerlInterpreter *my_perl;
129   - PMC *pmc = Parrot_pmc_new_noinit(interp, pmc_type(interp,
  129 + PMC *wrapper = Parrot_pmc_new_noinit(interp, pmc_type(interp,
130 130 string_from_literal(interp, "P5Scalar")));
131 131
132   - PObj_custom_mark_SET(pmc);
133   - PObj_custom_destroy_SET(pmc);
  132 + PObj_custom_mark_SET(wrapper);
  133 + PObj_custom_destroy_SET(wrapper);
134 134
135 135 GETATTR_P5Interpreter_my_perl(interp, p5i, my_perl);
136   - SETATTR_P5Scalar_p5i(interp, pmc, p5i);
137   - SETATTR_P5Scalar_sv(interp, pmc, SvREFCNT_inc(sv));
138   - return pmc;
  136 + SETATTR_P5Scalar_p5i(interp, wrapper, p5i);
  137 + SETATTR_P5Scalar_sv(interp, wrapper, SvREFCNT_inc(sv));
  138 + return wrapper;
139 139 }
140 140
141 141 /*
10 src/pmc/p5interpreter.pmc
@@ -162,14 +162,14 @@ Acquire a namespace handle.
162 162 */
163 163
164 164 METHOD PMC *get_namespace(STRING *name) {
165   - PMC *pmc = Parrot_pmc_new_noinit(interp, pmc_type(interp,
  165 + PMC *ns = Parrot_pmc_new_noinit(interp, pmc_type(interp,
166 166 string_from_literal(interp, "P5Namespace")));
167 167 /* Set up the underlying structure. */
168   - PObj_custom_mark_SET(pmc);
169   - SETATTR_P5Namespace_p5i(interp, pmc, SELF);
170   - SETATTR_P5Namespace_ns_name(interp, pmc, name);
  168 + PObj_custom_mark_SET(ns);
  169 + SETATTR_P5Namespace_p5i(interp, ns, SELF);
  170 + SETATTR_P5Namespace_ns_name(interp, ns, name);
171 171
172   - RETURN(PMC *pmc);
  172 + RETURN(PMC *ns);
173 173 }
174 174 }
175 175

0 comments on commit 5fa07ce

Please sign in to comment.
Something went wrong with that request. Please try again.