Commit 937a778e by Jakub Jelinek Committed by Jakub Jelinek

re PR preprocessor/92919 (invalid memory access in wide_str_to_charconst when…

re PR preprocessor/92919 (invalid memory access in wide_str_to_charconst when running ucn2.C testcase (caught by hwasan))

	PR preprocessor/92919
	* charset.c (wide_str_to_charconst): If str contains just the
	NUL terminator, punt quietly.

From-SVN: r279399
parent 8640a704
2019-12-14 Jakub Jelinek <jakub@redhat.com>
PR preprocessor/92919
* charset.c (wide_str_to_charconst): If str contains just the
NUL terminator, punt quietly.
2019-12-09 David Malcolm <dmalcolm@redhat.com> 2019-12-09 David Malcolm <dmalcolm@redhat.com>
* include/line-map.h (label_text::label_text): Make private. * include/line-map.h (label_text::label_text): Make private.
......
...@@ -1970,6 +1970,17 @@ wide_str_to_charconst (cpp_reader *pfile, cpp_string str, ...@@ -1970,6 +1970,17 @@ wide_str_to_charconst (cpp_reader *pfile, cpp_string str,
size_t off, i; size_t off, i;
cppchar_t result = 0, c; cppchar_t result = 0, c;
if (str.len <= nbwc)
{
/* Error recovery, if no errors have been diagnosed previously,
there should be at least two wide characters. Empty literals
are diagnosed earlier and we can get just the zero terminator
only if there were errors diagnosed during conversion. */
*pchars_seen = 0;
*unsignedp = 0;
return 0;
}
/* This is finicky because the string is in the target's byte order, /* This is finicky because the string is in the target's byte order,
which may not be our byte order. Only the last character, ignoring which may not be our byte order. Only the last character, ignoring
the NUL terminator, is relevant. */ the NUL terminator, is relevant. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment