Commit 79cc7f2f 79cc7f2fde35cb23f56bc245feb8625efa72118c by Sergey Poznyakoff

(_file_readline): Make sure the terminal zero is always added.

1 parent 4116d2d9
...@@ -102,6 +102,7 @@ _file_readline (stream_t stream, char *optr, size_t osize, ...@@ -102,6 +102,7 @@ _file_readline (stream_t stream, char *optr, size_t osize,
102 102
103 if (!fs->file) 103 if (!fs->file)
104 { 104 {
105 optr[0] = 0;
105 if (nbytes) 106 if (nbytes)
106 *nbytes = 0; 107 *nbytes = 0;
107 return 0; 108 return 0;
...@@ -131,6 +132,7 @@ _file_readline (stream_t stream, char *optr, size_t osize, ...@@ -131,6 +132,7 @@ _file_readline (stream_t stream, char *optr, size_t osize,
131 err = errno; 132 err = errno;
132 } 133 }
133 134
135 optr[n] = 0;
134 if (nbytes) 136 if (nbytes)
135 *nbytes = n; 137 *nbytes = n;
136 return err; 138 return err;
......