aboutsummaryrefslogtreecommitdiff
path: root/gcc/cpplib.c
diff options
context:
space:
mode:
authorNeil Booth <neil@gcc.gnu.org>2001-03-04 12:02:02 +0000
committerNeil Booth <neil@gcc.gnu.org>2001-03-04 12:02:02 +0000
commit7868b4a2520b831eec35cbabc7f28d3694aebbf4 (patch)
treed7897ebb45f49ac182f124043b11088aa89ca781 /gcc/cpplib.c
parent91c704c4589f1d5e2a9d4cf3e070b56907cf5f61 (diff)
downloadgcc-7868b4a2520b831eec35cbabc7f28d3694aebbf4.zip
gcc-7868b4a2520b831eec35cbabc7f28d3694aebbf4.tar.gz
gcc-7868b4a2520b831eec35cbabc7f28d3694aebbf4.tar.bz2
cppfiles.c (_cpp_execute_include): Don't make a null-terminated copy of the filename.
* cppfiles.c (_cpp_execute_include): Don't make a null-terminated copy of the filename. Don't use CPP_PREV_BUFFER. Don't call strlen or strcpy; we already know the length. (_cpp_compare_file_date): Similarly. * cpphash.h (struct cpp_reader): Delete done_initialising. (CPP_PREV_BUFFER): Delete. * cppinit.c (cpp_start_read): Don't set done_initialising. * cpplex.c (parse_string): Guarantee null-termination. (_cpp_equiv_toklists): Remove. * cpplib.c (glue_header_name): Null-terminate. (do_line): Don't leak memory. * cpplib.h (BT_WEAK): Delete. * cppmain.c (cb_ident): Strings are now null-terminated. From-SVN: r40233
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r--gcc/cpplib.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c
index 07f8fad..571e204 100644
--- a/gcc/cpplib.c
+++ b/gcc/cpplib.c
@@ -525,8 +525,9 @@ glue_header_name (pfile, header)
cpp_error (pfile, "missing terminating > character");
else
{
- token_mem = _cpp_pool_alloc (&pfile->ident_pool, total_len);
+ token_mem = _cpp_pool_alloc (&pfile->ident_pool, total_len + 1);
memcpy (token_mem, buffer, total_len);
+ token_mem[total_len] = '\0';
header->type = CPP_HEADER_NAME;
header->flags &= ~PREV_WHITE;
@@ -708,14 +709,10 @@ do_line (pfile)
if (token.type == CPP_STRING)
{
char *fname;
- unsigned int len;
+ unsigned int len = token.val.str.len + 1;
- /* FIXME: memory leak. */
- len = token.val.str.len;
- fname = xmalloc (len + 1);
+ fname = (char *) _cpp_pool_alloc (&pfile->ident_pool, len);
memcpy (fname, token.val.str.text, len);
- fname[len] = '\0';
-
_cpp_simplify_pathname (fname);
/* Only accept flags for the # 55 form. */