diff mbox series

Fix PR91236

Message ID alpine.LSU.2.20.1907241544250.30921@zhemvz.fhfr.qr
State New
Headers show
Series Fix PR91236 | expand

Commit Message

Richard Biener July 24, 2019, 1:45 p.m. UTC
The following fixes a stack corruption and a missed optimization.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2019-07-24  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91236
	* tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Fix
	size of CONSTRUCTOR write.  Fix buffer size we pass to
	native_encode_expr.
diff mbox series

Patch

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c	(revision 273758)
+++ gcc/tree-ssa-sccvn.c	(working copy)
@@ -1818,7 +1870,7 @@  vn_walk_cb_data::push_partial_def (const
       if (TREE_CODE (pd.rhs) == CONSTRUCTOR)
 	/* Empty CONSTRUCTOR.  */
 	memset (buffer + MAX (0, pd.offset),
-		0, MIN ((HOST_WIDE_INT)sizeof (buffer),
+		0, MIN ((HOST_WIDE_INT)sizeof (buffer) - MAX (0, pd.offset),
 			pd.size + MIN (0, pd.offset)));
       else
 	{
@@ -1833,7 +1885,7 @@  vn_walk_cb_data::push_partial_def (const
 	      pad = GET_MODE_SIZE (mode) - pd.size;
 	    }
 	  len = native_encode_expr (pd.rhs, buffer + MAX (0, pd.offset),
-				    sizeof (buffer - MAX (0, pd.offset)),
+				    sizeof (buffer) - MAX (0, pd.offset),
 				    MAX (0, -pd.offset) + pad);
 	  if (len <= 0 || len < (pd.size - MAX (0, -pd.offset)))
 	    {