diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2019-10-15 10:29:53 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2019-10-15 10:29:53 +0000 |
commit | 0186d373b63c998f0a1c911bdf76c7675f7708de (patch) | |
tree | 2a8099bd84eee1438551c237f5d4ed2569a75377 /gcc | |
parent | 0d552c1b67132b349ec77f725ceb1568d72c6134 (diff) | |
download | gcc-0186d373b63c998f0a1c911bdf76c7675f7708de.zip gcc-0186d373b63c998f0a1c911bdf76c7675f7708de.tar.gz gcc-0186d373b63c998f0a1c911bdf76c7675f7708de.tar.bz2 |
Fix unchecked use of tree_to_uhwi in tree-ssa-strlen.c
r273783 introduced an unchecked use of tree_to_uhwi. This is
tested by the SVE ACLE patches, but could potentially trigger
in non-SVE cases too.
2019-10-15 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* tree-ssa-strlen.c (count_nonzero_bytes): Check tree_fits_uhwi_p
before using tree_to_uhwi.
From-SVN: r276990
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/tree-ssa-strlen.c | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 23213c7..bf3dbe5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2019-10-15 Richard Sandiford <richard.sandiford@arm.com> + + * tree-ssa-strlen.c (count_nonzero_bytes): Check tree_fits_uhwi_p + before using tree_to_uhwi. + 2019-10-15 Ilya Leoshkevich <iii@linux.ibm.com> * config/s390/s390.md: Run %a0:DI splitters only after reload. diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index ef2717d..5b90ad3 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -4026,10 +4026,10 @@ count_nonzero_bytes (tree exp, unsigned HOST_WIDE_INT offset, /* The size of the MEM_REF access determines the number of bytes. */ tree type = TREE_TYPE (exp); - if (tree typesize = TYPE_SIZE_UNIT (type)) - nbytes = tree_to_uhwi (typesize); - else + tree typesize = TYPE_SIZE_UNIT (type); + if (!typesize || !tree_fits_uhwi_p (typesize)) return false; + nbytes = tree_to_uhwi (typesize); /* Handle MEM_REF = SSA_NAME types of assignments. */ return count_nonzero_bytes (arg, offset, nbytes, lenrange, nulterm, |