# endif
#endif
-#define TAINT_FROM_REGEX(sv,rx) \
- if ((rx)->exec_tainted) { \
- TAINT; \
- SvTAINTED_on(sv); \
- } \
- else \
- SvTAINTED_off(sv);
-
/*
* Use the "DESTRUCTOR" scope cleanup to reinstate magic.
*/
case '+':
if (curpm && (rx = curpm->op_pmregexp)) {
paren = rx->lastparen;
- if (!paren)
- return 0;
- goto getparen;
+ if (paren)
+ goto getparen;
}
return 0;
break;
case '`':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->subbeg)) {
+ if ((s = rx->subbeg) && rx->startp[0]) {
i = rx->startp[0] - s;
if (i >= 0)
return i;
return 0;
case '\'':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->endp[0])) {
- TAINT_IF(rx->exec_tainted);
- return (STRLEN) (rx->subend - s);
+ if (rx->subend && (s = rx->endp[0])) {
+ i = rx->subend - s;
+ if (i >= 0)
+ return 0;
}
}
return 0;
(t = rx->endp[paren]))
{
i = t - s;
+ getrx:
if (i >= 0) {
+ bool was_tainted;
+ if (tainting) {
+ was_tainted = tainted;
+ tainted = FALSE;
+ }
sv_setpvn(sv,s,i);
- TAINT_FROM_REGEX(sv,rx);
+ if (tainting)
+ tainted = was_tainted || rx->exec_tainted;
break;
}
}
break;
case '`':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->subbeg)) {
+ if ((s = rx->subbeg) && rx->startp[0]) {
i = rx->startp[0] - s;
- if (i >= 0) {
- sv_setpvn(sv,s,i);
- TAINT_FROM_REGEX(sv,rx);
- break;
- }
+ goto getrx;
}
}
sv_setsv(sv,&sv_undef);
break;
case '\'':
if (curpm && (rx = curpm->op_pmregexp)) {
- if ((s = rx->endp[0])) {
- sv_setpvn(sv,s, rx->subend - s);
- TAINT_FROM_REGEX(sv,rx);
- break;
+ if (rx->subend && (s = rx->endp[0])) {
+ i = rx->subend - s;
+ goto getrx;
}
}
sv_setsv(sv,&sv_undef);
sv_untaint(sv)
SV *sv;
{
- if (SvMAGICAL(sv)) {
+ if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
MAGIC *mg = mg_find(sv, 't');
if (mg)
mg->mg_len &= ~1;
sv_tainted(sv)
SV *sv;
{
- if (SvMAGICAL(sv)) {
+ if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) {
MAGIC *mg = mg_find(sv, 't');
if (mg && ((mg->mg_len & 1) || (mg->mg_len & 2) && mg->mg_obj == sv))
return TRUE;