mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-03-25 23:41:28 +08:00
re PR middle-end/53510 (OOM while compile some code)
PR middle-end/53510 * input.c (read_line): Use XRESIZEVEC instead of XNEWVEC to avoid leaking memory. No need to handle memory allocation failure. Double string_len on each reallocation instead of adding 2. * gcov.c (read_line): Likewise. From-SVN: r187952
This commit is contained in:
parent
4f7f7aca35
commit
92b05e72ea
@ -1,3 +1,12 @@
|
||||
2012-05-29 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR middle-end/53510
|
||||
* input.c (read_line): Use XRESIZEVEC instead of XNEWVEC
|
||||
to avoid leaking memory. No need to handle memory allocation
|
||||
failure. Double string_len on each reallocation instead of
|
||||
adding 2.
|
||||
* gcov.c (read_line): Likewise.
|
||||
|
||||
2012-05-29 Hans-Peter Nilsson <hp@axis.com>
|
||||
|
||||
* config/cris/cris.h (TARGET_HAS_BREAK, TARGET_TRAP_USING_BREAK8):
|
||||
|
11
gcc/gcov.c
11
gcc/gcov.c
@ -2219,15 +2219,8 @@ read_line (FILE *file)
|
||||
return string;
|
||||
}
|
||||
pos += len;
|
||||
ptr = XNEWVEC (char, string_len * 2);
|
||||
if (ptr)
|
||||
{
|
||||
memcpy (ptr, string, pos);
|
||||
string = ptr;
|
||||
string_len += 2;
|
||||
}
|
||||
else
|
||||
pos = 0;
|
||||
string = XRESIZEVEC (char, string, string_len * 2);
|
||||
string_len *= 2;
|
||||
}
|
||||
|
||||
return pos ? string : NULL;
|
||||
|
13
gcc/input.c
13
gcc/input.c
@ -1,5 +1,5 @@
|
||||
/* Data and functions related to line maps and input files.
|
||||
Copyright (C) 2004, 2007, 2008, 2009, 2010, 2011
|
||||
Copyright (C) 2004, 2007, 2008, 2009, 2010, 2011, 2012
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
@ -105,15 +105,8 @@ read_line (FILE *file)
|
||||
return string;
|
||||
}
|
||||
pos += len;
|
||||
ptr = XNEWVEC (char, string_len * 2);
|
||||
if (ptr)
|
||||
{
|
||||
memcpy (ptr, string, pos);
|
||||
string = ptr;
|
||||
string_len += 2;
|
||||
}
|
||||
else
|
||||
pos = 0;
|
||||
string = XRESIZEVEC (char, string, string_len * 2);
|
||||
string_len *= 2;
|
||||
}
|
||||
|
||||
return pos ? string : NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user