This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals


On Tue, Nov 12, 2013 at 04:33:41PM +0100, Dodji Seketeli wrote:
> +
> +      memmove (*line, l, len);
> +      (*line)[len - 1] = '\0';
> +      *line_len = --len;

Shouldn't this be testing that len > 0 && (*line)[len - 1] == '\n'
first before you decide to overwrite it and decrement len?
Though in that case there would be no '\0' termination of the string
for files not ending in a new-line.  So, either get_next_line should
append '\n' to the buffer, or you should have there space for that, or
you can't rely on zero termination of the string and need to use just
the length.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]