Skip to content
Snippets Groups Projects
Commit d8aeee11 authored by Jakub Jelinek's avatar Jakub Jelinek
Browse files

fold-const: Fix up a buffer overflow in native_encode_initializer [PR98407]

For flexible array members we need to incrementally clear just from
ptr + total_bytes up to new ptr + total_bytes, but memset has been called
with the length from ptr, so was missing - total_bytes.  Additionally,
in this code off is guaranteed to be -1 and thus o 0, so don't bother pretending
we could handle anything else, it would be more complicated than that.

2020-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/98407
	* fold-const.c (native_encode_initializer): When handling flexible
	array members, fix up computation of length for memset.  Also remove
	" - o" as o is always guaranteed to be 0 in this code path.

	* gcc.c-torture/compile/pr98407.c: New test.
parent b6237343
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment