Revision: 73099
          http://sourceforge.net/p/brlcad/code/73099
Author:   brlcad
Date:     2019-05-20 20:50:15 +0000 (Mon, 20 May 2019)
Log Message:
-----------
make sure the stream is valid

Modified Paths:
--------------
    brlcad/trunk/src/libbu/fgets.c

Modified: brlcad/trunk/src/libbu/fgets.c
===================================================================
--- brlcad/trunk/src/libbu/fgets.c      2019-05-20 19:36:07 UTC (rev 73098)
+++ brlcad/trunk/src/libbu/fgets.c      2019-05-20 20:50:15 UTC (rev 73099)
@@ -33,8 +33,8 @@
     int totBytesRead = 0;
     int isEOF = 0;
 
-    /* if we are not asked to read anything, just return */
-    if (UNLIKELY(size < 1)) {
+    /* if we are not asked to or can't read anything, just return */
+    if (UNLIKELY(size < 1 || !s)) {
        return s;
     }
 
@@ -47,7 +47,7 @@
     }
 
     /* check for EOF or error */
-    if (feof(stream) || ferror(stream)) {
+    if (UNLIKELY(!stream) || feof(stream) || ferror(stream)) {
        return (char *)NULL;
     }
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to