This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix weird warnings and/pr segfaults on binmode(,"encoding(...)")
authorNick Ing-Simmons <nik@tiuk.ti.com>
Sat, 27 Apr 2002 16:19:21 +0000 (16:19 +0000)
committerNick Ing-Simmons <nik@tiuk.ti.com>
Sat, 27 Apr 2002 16:19:21 +0000 (16:19 +0000)
- if encoding loads Encode then stack grows.
- pp_binmode was not allowing for that to happen
- added PUTBACK/SPAGAIN.

p4raw-id: //depot/perlio@16216

pp_sys.c

index 03b1634..0183325 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -731,11 +731,16 @@ PP(pp_binmode)
         RETPUSHUNDEF;
     }
 
+    PUTBACK;
     if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp),
-                       (discp) ? SvPV_nolen(discp) : Nullch))
+                       (discp) ? SvPV_nolen(discp) : Nullch)) {
+       SPAGAIN;
        RETPUSHYES;
-    else
+    }
+    else {
+       SPAGAIN;
        RETPUSHUNDEF;
+    }
 }
 
 PP(pp_tie)
@@ -4040,7 +4045,7 @@ PP(pp_system)
        TAINT_ENV();
        while (++MARK <= SP) {
            (void)SvPV_nolen(*MARK);      /* stringify for taint check */
-           if (PL_tainted) 
+           if (PL_tainted)
                break;
        }
        MARK = ORIGMARK;
@@ -4166,7 +4171,7 @@ PP(pp_exec)
        TAINT_ENV();
        while (++MARK <= SP) {
            (void)SvPV_nolen(*MARK);      /* stringify for taint check */
-           if (PL_tainted) 
+           if (PL_tainted)
                break;
        }
        MARK = ORIGMARK;