summaryrefslogtreecommitdiff
path: root/libcpp/mkdeps.c
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-15 20:08:57 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-10-15 20:08:57 +0000
commit15fc692a8e33d3b3bf82e8c9ae7f4572baac6e63 (patch)
tree9638e29aa7f7e52938c01390081a134c642b7a02 /libcpp/mkdeps.c
parent57b3787917fb9d6711e03f20ca7fbea66a5ed5b6 (diff)
downloadgcc-15fc692a8e33d3b3bf82e8c9ae7f4572baac6e63.tar.gz
2012-10-15 Tobias Burnus <burnus@net-b.de>
* files.c (read_file_guts, _cpp_save_file_entries): Free memory before returning. * lex.c (warn_about_normalization): Ditto. * mkdeps.c (deps_save): Ditto. * pch.c (cpp_valid_state): Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@192474 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/mkdeps.c')
-rw-r--r--libcpp/mkdeps.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libcpp/mkdeps.c b/libcpp/mkdeps.c
index af11ac3a6e3..b57681392a6 100644
--- a/libcpp/mkdeps.c
+++ b/libcpp/mkdeps.c
@@ -399,25 +399,33 @@ deps_restore (struct deps *deps, FILE *fd, const char *self)
unsigned int i, count;
size_t num_to_read;
size_t buf_size = 512;
- char *buf = XNEWVEC (char, buf_size);
+ char *buf;
/* Number of dependences. */
if (fread (&count, 1, sizeof (count), fd) != sizeof (count))
return -1;
+ buf = XNEWVEC (char, buf_size);
+
/* The length of each dependence string, followed by the string. */
for (i = 0; i < count; i++)
{
/* Read in # bytes in string. */
if (fread (&num_to_read, 1, sizeof (size_t), fd) != sizeof (size_t))
- return -1;
+ {
+ free (buf);
+ return -1;
+ }
if (buf_size < num_to_read + 1)
{
buf_size = num_to_read + 1 + 127;
buf = XRESIZEVEC (char, buf, buf_size);
}
if (fread (buf, 1, num_to_read, fd) != num_to_read)
- return -1;
+ {
+ free (buf);
+ return -1;
+ }
buf[num_to_read] = '\0';
/* Generate makefile dependencies from .pch if -nopch-deps. */