[5/6] Preprocessor include
authorNathan Sidwell <nathan@acm.org>
Wed, 31 Oct 2018 15:03:04 +0000 (15:03 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 31 Oct 2018 15:03:04 +0000 (15:03 +0000)
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02041.html
* directives.c (do_include_common): Commonize cleanup path.
(_cpp_pop_buffer): Fix leak.

From-SVN: r265690

libcpp/ChangeLog
libcpp/directives.c

index 42433d9fe123c71e452b728e03ec6ad4bfa7bf1a..c5a0285b57f174eeb4a540fcdcea2db2e1a0cef2 100644 (file)
@@ -1,5 +1,8 @@
 2018-10-31  Nathan Sidwell  <nathan@acm.org>
 
+       * directives.c (do_include_common): Commonize cleanup path.
+       (_cpp_pop_buffer): Fix leak.
+
        * include/line-map.h (IS_ORDINARY_LOC, IS_MACRO_LOC): New
        predicates.
        (IS_ADHOC_LOC): Move earlier.
index b91c2e918a5378c1fb711ce021038d09d8837246..a76631d93663808b8ee6d9f66cbde9825265c20f 100644 (file)
@@ -822,22 +822,15 @@ do_include_common (cpp_reader *pfile, enum include_type type)
 
   fname = parse_include (pfile, &angle_brackets, &buf, &location);
   if (!fname)
-    {
-      if (buf)
-       XDELETEVEC (buf);
-      return;
-    }
+    goto done;
 
   if (!*fname)
-  {
-    cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
-                        "empty filename in #%s",
-                        pfile->directive->name);
-    XDELETEVEC (fname);
-    if (buf)
-      XDELETEVEC (buf);
-    return;
-  }
+    {
+      cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
+                          "empty filename in #%s",
+                          pfile->directive->name);
+      goto done;
+    }
 
   /* Prevent #include recursion.  */
   if (pfile->line_table->depth >= CPP_STACK_MAX)
@@ -855,6 +848,7 @@ do_include_common (cpp_reader *pfile, enum include_type type)
       _cpp_stack_include (pfile, fname, angle_brackets, type, location);
     }
 
+ done:
   XDELETEVEC (fname);
   if (buf)
     XDELETEVEC (buf);
@@ -2613,6 +2607,8 @@ _cpp_pop_buffer (cpp_reader *pfile)
 
       _cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0);
     }
+  else if (to_free)
+    free ((void *)to_free);
 }
 
 /* Enter all recognized directives in the hash table.  */