aboutsummaryrefslogtreecommitdiffstats
path: root/prog/prog.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-03-05 15:14:07 +0100
committerAleksandr Nogikh <nogikh@google.com>2024-03-13 10:31:21 +0000
commit76713834e4ab721bc6265c89203ee171152cc017 (patch)
tree2b90974afdfb8653a7ba660adb167cb370750c05 /prog/prog.go
parentdb5b7ff0c1508e1f6bc77ba4df578cabb88b9914 (diff)
prog: fix resource leak during replaceArg() of union fields
The replaced union field may contain resource references that must also be cleaned up. The bug was triggered via methods that patch conditional fields, so let's add stress tests for the conditional fields + resources combination. Reported-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'prog/prog.go')
-rw-r--r--prog/prog.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/prog/prog.go b/prog/prog.go
index 34fcfa6e8..f93293b64 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -362,6 +362,9 @@ func replaceArg(arg, arg1 Arg) {
case *PointerArg:
*a = *arg1.(*PointerArg)
case *UnionArg:
+ if a.Option != nil {
+ removeArg(a.Option)
+ }
*a = *arg1.(*UnionArg)
case *DataArg:
*a = *arg1.(*DataArg)