(_file_readline): Make sure the terminal zero is always added.
Showing
1 changed file
with
2 additions
and
0 deletions
... | @@ -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; | ... | ... |
-
Please register or sign in to post a comment