aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRafael Avila de Espindola <espindola@google.com>2009-11-16 20:25:42 +0000
committerRafael Espindola <espindola@gcc.gnu.org>2009-11-16 20:25:42 +0000
commit1b70729f701d8533f926fca8e2df40b2819fbc31 (patch)
treedaac8a3805e98a02d32f922a7c26d2d5abf2fe62 /gcc
parentefd0b0d36de2b536225b81804587915e3440c1c0 (diff)
downloadgcc-1b70729f701d8533f926fca8e2df40b2819fbc31.zip
gcc-1b70729f701d8533f926fca8e2df40b2819fbc31.tar.gz
gcc-1b70729f701d8533f926fca8e2df40b2819fbc31.tar.bz2
lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset.
2009-11-16 Rafael Avila de Espindola <espindola@google.com> * lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset. From-SVN: r154215
Diffstat (limited to 'gcc')
-rw-r--r--gcc/lto/ChangeLog4
-rw-r--r--gcc/lto/lto-elf.c15
2 files changed, 14 insertions, 5 deletions
diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog
index 9633199..b37c549 100644
--- a/gcc/lto/ChangeLog
+++ b/gcc/lto/ChangeLog
@@ -1,3 +1,7 @@
+2009-11-16 Rafael Avila de Espindola <espindola@google.com>
+
+ * lto-elf.c (lto_elf_file_open): Use strtoll to parse the offset.
+
2009-11-14 Jan Hubicka <jh@suse.cz>
* lto.c (read_cgraph_and_symbols): Set also ipa_transforms_to_apply.
diff --git a/gcc/lto/lto-elf.c b/gcc/lto/lto-elf.c
index ee587f7..bc8e137 100644
--- a/gcc/lto/lto-elf.c
+++ b/gcc/lto/lto-elf.c
@@ -540,7 +540,7 @@ lto_file *
lto_elf_file_open (const char *filename, bool writable)
{
lto_elf_file *elf_file;
- lto_file *result;
+ lto_file *result = NULL;
off_t offset;
const char *offset_p;
char *fname;
@@ -553,13 +553,17 @@ lto_elf_file_open (const char *filename, bool writable)
}
else
{
- int64_t t;
fname = (char *) xmalloc (offset_p - filename + 1);
memcpy (fname, filename, offset_p - filename);
fname[offset_p - filename] = '\0';
offset_p++;
- sscanf(offset_p, "%" PRId64 , &t);
- offset = t;
+ errno = 0;
+ offset = strtoll (offset_p, NULL, 10);
+ if (errno != 0)
+ {
+ error ("could not parse offset %s", offset_p);
+ goto fail;
+ }
/* elf_rand expects the offset to point to the ar header, not the
object itself. Subtract the size of the ar header (60 bytes).
We don't uses sizeof (struct ar_hd) to avoid including ar.h */
@@ -631,7 +635,8 @@ lto_elf_file_open (const char *filename, bool writable)
return result;
fail:
- lto_elf_file_close (result);
+ if (result)
+ lto_elf_file_close (result);
return NULL;
}