2018-09-13 Bernd Edlinger <bernd.edlinger@hotmail.de>
+ * fold-const.c (c_getstr): Clamp STRING_LENGTH to STRING_SIZE.
+
* varasm.c (compare_constant): Compare type size of STRING_CSTs.
(get_constant_size): Don't make STRING_CSTs larger than they are.
(check_string_literal): New check function for STRING_CSTs.
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;