diff lib-src/make-docfile.c @ 112440:b5017c649dfb

Check return values of some library calls.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 22 Jan 2011 23:30:19 -0800
parents 56d3e9c28eb0
children
line wrap: on
line diff
--- a/lib-src/make-docfile.c	Sat Jan 22 20:33:12 2011 -0800
+++ b/lib-src/make-docfile.c	Sat Jan 22 23:30:19 2011 -0800
@@ -158,7 +158,11 @@
     }
   if (argc > i + 1 && !strcmp (argv[i], "-d"))
     {
-      chdir (argv[i + 1]);
+      if (chdir (argv[i + 1]) != 0)
+	{
+	  perror (argv[i + 1]);
+	  return EXIT_FAILURE;
+	}
       i += 2;
     }
 
@@ -648,6 +652,7 @@
 
 	      if (defunflag && (commas == 1 || commas == 2))
 		{
+		  int scanned = 0;
 		  do
 		    c = getc (infile);
 		  while (c == ' ' || c == '\n' || c == '\r' || c == '\t');
@@ -655,12 +660,14 @@
 		    goto eof;
 		  ungetc (c, infile);
 		  if (commas == 2) /* pick up minargs */
-		    fscanf (infile, "%d", &minargs);
+		    scanned = fscanf (infile, "%d", &minargs);
 		  else /* pick up maxargs */
 		    if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
 		      maxargs = -1;
 		    else
-		      fscanf (infile, "%d", &maxargs);
+		      scanned = fscanf (infile, "%d", &maxargs);
+		  if (scanned < 0)
+		    goto eof;
 		}
 	    }