Skip to content

Commit 481a1c3

Browse files
Steve WishnouskyColin Robertson
authored andcommitted
Update fread() clobber conditions (MicrosoftDocs#584)
I said we may clobber when the amount read is greater than 4k, but it's greater than or equal to.
1 parent dcb18f3 commit 481a1c3

File tree

1 file changed

+1
-1
lines changed
  • docs/c-runtime-library/reference

1 file changed

+1
-1
lines changed

docs/c-runtime-library/reference/fread.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ See [\_doserrno, errno, \_sys\_errlist, and \_sys\_nerr](../../c-runtime-library
4747

4848
The **fread** function reads up to *count* items of *size* bytes from the input *stream* and stores them in *buffer*. The file pointer associated with *stream* (if there is one) is increased by the number of bytes actually read. If the given stream is opened in [text mode](../../c-runtime-library/text-and-binary-mode-file-i-o.md), Windows-style newlines are converted into Unix-style newlines. That is, carriage return-linefeed (CRLF) pairs are replaced by single linefeed (LF) characters. The replacement has no effect on the file pointer or the return value. The file-pointer position is indeterminate if an error occurs. The value of a partially read item cannot be determined.
4949

50-
When used on a text mode stream, if the amount of data requested (that is, *size* \* *count*) is greater than the internal **FILE** \* buffer size (by default this is 4096 bytes, configurable by using [setvbuf](../../c-runtime-library/reference/setvbuf.md)), stream data is copied directly into the user-provided buffer, and newline conversion is done in that buffer. Since the converted data may be shorter than the stream data copied into the buffer, data past *buffer*\[*return_value* \* *size*] (where *return_value* is the return value from **fread**) may contain unconverted data from the file. For this reason, we recommend you null-terminate character data at *buffer*\[*return_value* \* *size*] if the intent of the buffer is to act as a C-style string. See [fopen](fopen-wfopen.md) for details on the effects of text mode and binary mode.
50+
When used on a text mode stream, if the amount of data requested (that is, *size* \* *count*) is greater than or equal to the internal **FILE** \* buffer size (by default this is 4096 bytes, configurable by using [setvbuf](../../c-runtime-library/reference/setvbuf.md)), stream data is copied directly into the user-provided buffer, and newline conversion is done in that buffer. Since the converted data may be shorter than the stream data copied into the buffer, data past *buffer*\[*return_value* \* *size*] (where *return_value* is the return value from **fread**) may contain unconverted data from the file. For this reason, we recommend you null-terminate character data at *buffer*\[*return_value* \* *size*] if the intent of the buffer is to act as a C-style string. See [fopen](fopen-wfopen.md) for details on the effects of text mode and binary mode.
5151

5252
This function locks out other threads. If you need a non-locking version, use **_fread_nolock**.
5353

0 commit comments

Comments
 (0)