/* Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved.
+ * Copyright (C) 2014, cPanel Inc. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the same terms as Perl itself.
*/
CV *cv = NULL;
GV *gv;
HV *stash = CopSTASH(PL_curcop);
- char *s, *end = NULL, saved;
+ char *s, *end = NULL;
MAGIC *mg;
PPCODE:
if (!SvROK(sub) && SvGMAGICAL(sub))
end = s;
}
s--;
- if (end) {
- saved = *end;
- *end = 0;
- stash = GvHV(gv_fetchpv(name, TRUE, SVt_PVHV));
- *end = saved;
- name = end;
- }
+ if (end) {
+ char *namepv = savepvn(name, end - name);
+ stash = GvHV(gv_fetchpv(namepv, TRUE, SVt_PVHV));
+ Safefree(namepv);
+ name = end;
+ }
gv = (GV *) newSV(0);
gv_init(gv, stash, name, s - name, TRUE);