Skip to content

Commit d7e34a5

Browse files
author
nathan
committed
[5/6] Preprocessor include
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg02041.html * directives.c (do_include_common): Commonize cleanup path. (_cpp_pop_buffer): Fix leak. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265690 138bc75d-0d04-0410-961f-82ee72b054a4
1 parent 431aa89 commit d7e34a5

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

libcpp/ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
2018-10-31 Nathan Sidwell <[email protected]>
22

3+
* directives.c (do_include_common): Commonize cleanup path.
4+
(_cpp_pop_buffer): Fix leak.
5+
36
* include/line-map.h (IS_ORDINARY_LOC, IS_MACRO_LOC): New
47
predicates.
58
(IS_ADHOC_LOC): Move earlier.

libcpp/directives.c

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -822,22 +822,15 @@ do_include_common (cpp_reader *pfile, enum include_type type)
822822

823823
fname = parse_include (pfile, &angle_brackets, &buf, &location);
824824
if (!fname)
825-
{
826-
if (buf)
827-
XDELETEVEC (buf);
828-
return;
829-
}
825+
goto done;
830826

831827
if (!*fname)
832-
{
833-
cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
834-
"empty filename in #%s",
835-
pfile->directive->name);
836-
XDELETEVEC (fname);
837-
if (buf)
838-
XDELETEVEC (buf);
839-
return;
840-
}
828+
{
829+
cpp_error_with_line (pfile, CPP_DL_ERROR, location, 0,
830+
"empty filename in #%s",
831+
pfile->directive->name);
832+
goto done;
833+
}
841834

842835
/* Prevent #include recursion. */
843836
if (pfile->line_table->depth >= CPP_STACK_MAX)
@@ -855,6 +848,7 @@ do_include_common (cpp_reader *pfile, enum include_type type)
855848
_cpp_stack_include (pfile, fname, angle_brackets, type, location);
856849
}
857850

851+
done:
858852
XDELETEVEC (fname);
859853
if (buf)
860854
XDELETEVEC (buf);
@@ -2613,6 +2607,8 @@ _cpp_pop_buffer (cpp_reader *pfile)
26132607

26142608
_cpp_do_file_change (pfile, LC_LEAVE, 0, 0, 0);
26152609
}
2610+
else if (to_free)
2611+
free ((void *)to_free);
26162612
}
26172613

26182614
/* Enter all recognized directives in the hash table. */

0 commit comments

Comments
 (0)