From 4097c8d7a8596ddbc9a9db7b7f39c5cbdb1bd742 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 6 Mar 2024 14:47:02 +0100 Subject: sys/linux: clone args before mutation Not cloning the argument results in replaceArg() replacing a union argument with itself, which may lead to inconsistent resource references. Add an assertion to detect such cases in the future. --- prog/clone.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'prog/clone.go') diff --git a/prog/clone.go b/prog/clone.go index 029cf94c4..4523be0eb 100644 --- a/prog/clone.go +++ b/prog/clone.go @@ -39,6 +39,10 @@ func cloneCall(c *Call, newargs map[*ResultArg]*ResultArg) *Call { return c1 } +func CloneArg(arg Arg) Arg { + return clone(arg, nil) +} + func clone(arg Arg, newargs map[*ResultArg]*ResultArg) Arg { var arg1 Arg switch a := arg.(type) { -- cgit mrf-deployment