summaryrefslogtreecommitdiff
path: root/doio.c
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2002-06-20 16:54:01 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2002-06-20 16:54:01 +0000
commita33cf58c90e96ed3c4b1c1fdbaf666d924440940 (patch)
treeac94fca4da7662586ad127815a392c6a5bc9f0fe /doio.c
parent41fcf1b2dde238cf584df7c8f5fb4cb1e68314f5 (diff)
downloadperl-a33cf58c90e96ed3c4b1c1fdbaf666d924440940.tar.gz
Fix segv on IO::File->open("/dev/null").
p4raw-id: //depot/perlio@17327
Diffstat (limited to 'doio.c')
-rw-r--r--doio.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/doio.c b/doio.c
index 0be42df8c1..20f6fb3e99 100644
--- a/doio.c
+++ b/doio.c
@@ -663,7 +663,10 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
if (writing) {
if (IoTYPE(io) == IoTYPE_SOCKET
|| (IoTYPE(io) == IoTYPE_WRONLY && fd >= 0 && S_ISCHR(PL_statbuf.st_mode)) ) {
- mode[0] = 'w';
+ char *s = mode;
+ if (*s == 'I' || *s == '#')
+ s++;
+ *s = 'w';
if (!(IoOFP(io) = PerlIO_openn(aTHX_ type,mode,fd,0,0,NULL,0,svp))) {
PerlIO_close(fp);
IoIFP(io) = Nullfp;