From: Michael Beck Date: Thu, 24 Jun 2004 15:03:29 +0000 (+0000) Subject: An ir_node may be even smaller than a struct ir_node, so make right copy X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=d61a9a7a1dc459e8089092eeb8d325f99e6e0196;p=libfirm An ir_node may be even smaller than a struct ir_node, so make right copy to shut up valgrind (and prevend possible segfaults) [r3206] --- diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index ce0e56975..a60667777 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -1568,8 +1568,12 @@ optimize_node (ir_node *n) * we MUST copy the node here temparary, because it's still needed * for DBG_OPT_ALGSIM0 */ - ir_node x = *n; - oldn = &x; + int node_size = offsetof(ir_node, attr) + n->op->attr_size; + ir_node *x = alloca(node_size); + + memcpy(x, n, node_size); + oldn = x; + /* evaluation was successful -- replace the node. */ obstack_free (current_ir_graph->obst, n); n = new_Const (get_tarval_mode (tv), tv);