This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PCH] fix memory-allocation bug in cpp_read_state
- From: Geoffrey Keating <gkeating at apple dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 Nov 2002 10:21:26 -0800 (PST)
- Subject: [PCH] fix memory-allocation bug in cpp_read_state
Obvious bug.
Tested by running pch.exp on powerpc-darwin.
--
- Geoffrey Keating <geoffk@apple.com>
===File ~/patches/pchbranch-cppreadstatedefn.patch==========
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ChangeLog,v
retrieving revision 1.12690.2.81
diff -u -p -u -p -r1.12690.2.81 ChangeLog
--- ChangeLog 15 Nov 2002 16:44:16 -0000 1.12690.2.81
+++ ChangeLog 15 Nov 2002 18:20:32 -0000
@@ -1,3 +1,7 @@
+2002-11-15 Geoffrey Keating <geoffk@apple.com>
+
+ * cpppch.c (cpp_read_state): Correct size reallocated for 'defn'.
+
2002-11-14 Geoffrey Keating <geoffk@apple.com>
* optabs.h (code_to_optab): Add GTY marker.
Index: cpppch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/cpppch.c,v
retrieving revision 1.1.4.3
diff -u -p -u -p -r1.1.4.3 cpppch.c
--- cpppch.c 9 Nov 2002 01:12:21 -0000 1.1.4.3
+++ cpppch.c 15 Nov 2002 18:20:32 -0000
@@ -609,9 +609,8 @@ cpp_read_state (r, name, f, data)
if (defnlen < m.definition_length + 1)
{
- free (defn);
defnlen = m.definition_length + 256;
- defn = xmalloc (m.definition_length);
+ defn = xrealloc (defn, defnlen);
}
if (fread (defn, 1, m.definition_length, f) != m.definition_length)
============================================================