summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2001-03-01 22:58:36 +0000
committerManuel Novoa III <mjn3@codepoet.org>2001-03-01 22:58:36 +0000
commit0543518c73248d50c60139511b02e75026399de0 (patch)
tree72ba2883a2c93fd5a521bb975ea097f61bbbbdfc
parent9aed53cc26d900ab64f49c38df535cf10518aa51 (diff)
Stupid buglet fix. Don't trash FILE bufstart if buffer allocation fails.
-rw-r--r--libc/stdio/stdio.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index 0522c1b5d..0baedcdf3 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -52,17 +52,8 @@ extern off_t _uClibc_fwrite(const unsigned char *buf, off_t bytes, FILE *fp);
extern off_t _uClibc_fread(unsigned char *buf, off_t bytes, FILE *fp);
/* Note: This def of READING is ok since 1st ungetc puts in buf. */
-#if 0
-#define READING(fp) (fp->bufpos < fp->bufread)
-#else
#define READING(fp) (fp->bufstart < fp->bufread)
-#endif
-
-#if 1
#define WRITING(fp) (fp->bufwrite > fp->bufstart)
-#else
-#define WRITING(fp) ((fp->bufpos > fp->bufread) && (fp->bufpos > fp->bufstart))
-#endif
#define READABLE(fp) (fp->bufread != 0)
#define WRITEABLE(fp) (fp->bufwrite != 0)
@@ -657,6 +648,7 @@ FILE *fp;
const char *mode;
{
FILE *nfp;
+ unsigned char *p;
int open_mode;
int cur_mode;
@@ -729,8 +721,9 @@ const char *mode;
nfp->next = __IO_list; /* use newly created FILE and */
__IO_list = nfp; /* add it to the list of open files. */
- if ((nfp->bufstart = _alloc_stdio_buffer(BUFSIZ)) != 0) {
- nfp->bufend = nfp->bufstart + BUFSIZ;
+ if ((p = _alloc_stdio_buffer(BUFSIZ)) != 0) {
+ nfp->bufstart = p;
+ nfp->bufend = p + BUFSIZ;
nfp->mode |= __MODE_FREEBUF;
}
}