Use -std option in test for C99 macros in <cmath>
[gcc.git] / libcpp / mkdeps.c
index af11ac3a6e324d635b8abbacdc9015f07cb37c37..32ef627868343378059c2dd30c6e38a08123b485 100644 (file)
@@ -1,6 +1,5 @@
 /* Dependency generator for Makefile fragments.
-   Copyright (C) 2000, 2001, 2003, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 2000-2016 Free Software Foundation, Inc.
    Contributed by Zack Weinberg, Mar 2000
 
 This program is free software; you can redistribute it and/or modify it
@@ -399,25 +398,33 @@ deps_restore (struct deps *deps, FILE *fd, const char *self)
   unsigned int i, count;
   size_t num_to_read;
   size_t buf_size = 512;
-  char *buf = XNEWVEC (char, buf_size);
+  char *buf;
 
   /* Number of dependences.  */
   if (fread (&count, 1, sizeof (count), fd) != sizeof (count))
     return -1;
 
+  buf = XNEWVEC (char, buf_size);
+
   /* The length of each dependence string, followed by the string.  */
   for (i = 0; i < count; i++)
     {
       /* Read in # bytes in string.  */
       if (fread (&num_to_read, 1, sizeof (size_t), fd) != sizeof (size_t))
-       return -1;
+       {
+         free (buf);
+         return -1;
+       }
       if (buf_size < num_to_read + 1)
        {
          buf_size = num_to_read + 1 + 127;
          buf = XRESIZEVEC (char, buf, buf_size);
        }
       if (fread (buf, 1, num_to_read, fd) != num_to_read)
-       return -1;
+       {
+         free (buf);
+         return -1;
+       }
       buf[num_to_read] = '\0';
 
       /* Generate makefile dependencies from .pch if -nopch-deps.  */