shithub: mc

Download patch

ref: 11d385224d630ae234c7e8c4212cfefac8fd167d
parent: 7439e43b38569064395880551b1541db79bcfed5
author: iriri <iri@konnichiwastevenspielbergde.su>
date: Sat Jul 21 21:17:49 EDT 2018

Add zeroed env pointer when a const fn is passed as an argument.

This makes it safe to fndup a global function which makes it safe to spawn a global function.

--- a/6/simp.c
+++ b/6/simp.c
@@ -298,7 +298,7 @@
 Node *
 loadvar(Simp *s, Node *n, Node *dst)
 {
-	Node *p, *f, *r;
+	Node *p, *f, *r, *e;
 
 	if (isconstfn(n)) {
 		if (dst)
@@ -308,6 +308,9 @@
 		f = getcode(s, n);
 		p = addr(s, r, exprtype(n));
 		assignat(s, p, Ptrsz, f);
+		e = mkintlit(n->loc, 0);
+		e->expr.type = tyintptr;
+		assignat(s, p, 0, e);
 	} else {
 		r = n;
 	}