xiaoxiang781216 commented on code in PR #10358:
URL: https://github.com/apache/nuttx/pull/10358#discussion_r1303249802


##########
libs/libc/stdio/lib_libfread.c:
##########
@@ -51,6 +51,7 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE 
*stream)
   size_t remaining = count;
 #ifndef CONFIG_STDIO_DISABLE_BUFFERING
   int ret;
+  size_t gulp_size;

Review Comment:
   move before line 53



##########
libs/libc/stdio/lib_libfread.c:
##########
@@ -121,12 +122,25 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE 
*stream)
             {
               /* Is there readable data in the buffer? */
 
-              while (remaining > 0 && stream->fs_bufpos < stream->fs_bufread)
+              gulp_size = stream->fs_bufread - stream->fs_bufpos;
+
+              /* Avoid empty buffers or read requests greater than the size
+               *  buffer remaining
+               */
+
+              if (gulp_size <= CONFIG_STDIO_BUFFER_SIZE || count < gulp_size)

Review Comment:
   ```suggestion
                 if (gulp_size > 0)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to