cpplib.c (do_pragma_implementation): Fix off-by-one error truncating a string.
* cpplib.c (do_pragma_implementation): Fix off-by-one error truncating a string. Don't assume tokens are nul terminated. Problem noted by Andreas Jaeger <aj@suse.de> From-SVN: r32507
This commit is contained in:
parent
bc808e0bc5
commit
0e091b520e
@ -1,3 +1,9 @@
|
||||
2000-03-13 Zack Weinberg <zack@wolery.cumb.org>
|
||||
|
||||
* cpplib.c (do_pragma_implementation): Fix off-by-one error
|
||||
truncating a string. Don't assume tokens are nul terminated.
|
||||
Problem noted by Andreas Jaeger <aj@suse.de>
|
||||
|
||||
2000-03-13 Jason Merrill <jason@casey.cygnus.com>
|
||||
|
||||
* dwarf2out.c (add_name_and_src_coords_attributes): Only add
|
||||
|
@ -1705,11 +1705,12 @@ do_pragma_implementation (pfile)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Trim the leading and trailing quote marks from the string. */
|
||||
name = pfile->token_buffer + written + 1;
|
||||
len = strlen (name);
|
||||
len = CPP_PWRITTEN (pfile) - name;
|
||||
copy = (U_CHAR *) alloca (len);
|
||||
memcpy (copy, name, len - 1);
|
||||
copy[len] = '\0'; /* trim trailing quote */
|
||||
copy[len - 1] = '\0';
|
||||
|
||||
if (cpp_included (pfile, copy))
|
||||
cpp_warning (pfile,
|
||||
|
7
gcc/testsuite/gcc.dg/pr-impl.c
Normal file
7
gcc/testsuite/gcc.dg/pr-impl.c
Normal file
@ -0,0 +1,7 @@
|
||||
/* Test warnings generated by #pragma implementation in the wrong place. */
|
||||
/* { dg-do preprocess } */
|
||||
|
||||
#pragma implementation "stdlib.h" /* { dg-bogus "appears after" "stdlib.h" } */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#pragma implementation "stdio.h" /* { dg-warning "appears after" "stdio.h" } */
|
Loading…
Reference in New Issue
Block a user