aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 71c18eb..9fc7fc5 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -14611,6 +14611,10 @@ c_getstr (tree src, unsigned HOST_WIDE_INT *strlen /* = NULL */,
const char *string = TREE_STRING_POINTER (src);
+ /* Ideally this would turn into a gcc_checking_assert over time. */
+ if (string_length > string_size)
+ string_length = string_size;
+
if (string_length == 0
|| offset >= string_size)
return NULL;