Fixed four off by ones (undefined string termination)

This commit is contained in:
Pierre Pronchery 2008-05-27 01:24:12 +00:00
parent e6cf667584
commit 184130ccf0

View File

@ -229,7 +229,7 @@ static char * _cpp_parse_line(Parser * parser, int c)
do do
{ {
if((p = realloc(str, len + 1)) == NULL) if((p = realloc(str, len + 2)) == NULL)
{ {
error_set_code(1, "%s", strerror(errno)); error_set_code(1, "%s", strerror(errno));
free(str); free(str);
@ -253,7 +253,7 @@ static char * _cpp_parse_word(Parser * parser, int c)
do do
{ {
if((p = realloc(str, len + 1)) == NULL) if((p = realloc(str, len + 2)) == NULL)
{ {
error_set_code(1, "%s", strerror(errno)); error_set_code(1, "%s", strerror(errno));
free(str); free(str);
@ -439,7 +439,7 @@ static int _cpp_callback_whitespace(Parser * parser, Token * token, int c,
{ {
if(c != '\n') if(c != '\n')
continue; continue;
if((p = realloc(str, len + 1)) == NULL) if((p = realloc(str, len + 2)) == NULL)
{ {
free(str); free(str);
return -1; return -1;
@ -495,7 +495,7 @@ static int _cpp_callback_otherspace(Parser * parser, Token * token, int c,
#endif #endif
do do
{ {
if((p = realloc(str, len + 1)) == NULL) if((p = realloc(str, len + 2)) == NULL)
{ {
free(str); free(str);
return -1; return -1;