From 46b57440a0663cbe33346e75195dfbc2c87024c3 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 30 Jun 1989 14:46:27 +0000 Subject: [PATCH] made a bit more robust --- modules/src/system/close.c | 8 +++++--- modules/src/system/read.c | 1 + modules/src/system/seek.c | 1 + modules/src/system/write.c | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/src/system/close.c b/modules/src/system/close.c index 350b72aaf..3cfcf340f 100644 --- a/modules/src/system/close.c +++ b/modules/src/system/close.c @@ -9,7 +9,9 @@ sys_close(fp) register File *fp; { - fp->o_flags = 0; - close(fp->o_fd); - fp->o_fd = -1; + if (fp) { + fp->o_flags = 0; + close(fp->o_fd); + fp->o_fd = -1; + } } diff --git a/modules/src/system/read.c b/modules/src/system/read.c index 11802347b..b88d9d00e 100644 --- a/modules/src/system/read.c +++ b/modules/src/system/read.c @@ -12,5 +12,6 @@ sys_read(fp, bufptr, bufsiz, pnbytes) char *bufptr; int bufsiz, *pnbytes; { + if (! fp) return 0; return (*pnbytes = read(fp->o_fd, bufptr, bufsiz)) >= 0; } diff --git a/modules/src/system/seek.c b/modules/src/system/seek.c index 2d742fac1..132a5fcab 100644 --- a/modules/src/system/seek.c +++ b/modules/src/system/seek.c @@ -14,5 +14,6 @@ sys_seek(fp, off, whence, poff) long off; long *poff; { + if (! fp) return 0; return (*poff = lseek(fp->o_fd, off, whence)) >= 0; } diff --git a/modules/src/system/write.c b/modules/src/system/write.c index 582ecd3de..dd98446e0 100644 --- a/modules/src/system/write.c +++ b/modules/src/system/write.c @@ -12,5 +12,6 @@ sys_write(fp, bufptr, nbytes) char *bufptr; int nbytes; { + if (! fp) return 0; return write(fp->o_fd, bufptr, nbytes) == nbytes; }