Skip to content

Commit 175c492

Browse files
authored
fix(handle): call to ddwaf_init is missing a call to unsafe.KeepAlive (#112)
Signed-off-by: Eliott Bouhana <[email protected]>
1 parent 24e43d9 commit 175c492

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

handle.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ func NewHandle(rules any, keyObfuscatorRegex string, valueObfuscatorRegex string
6666
diagnosticsWafObj := new(bindings.WafObject)
6767
defer wafLib.WafObjectFree(diagnosticsWafObj)
6868

69-
unsafe.KeepAlive(encoder.cgoRefs)
69+
cHandle := wafLib.WafInit(obj, config, diagnosticsWafObj)
70+
unsafe.KeepAlive(encoder.cgoRefs) // Keep this AFTER the call to wafLib.WafInit
7071

71-
return newHandle(wafLib.WafInit(obj, config, diagnosticsWafObj), diagnosticsWafObj)
72+
return newHandle(cHandle, diagnosticsWafObj)
7273
}
7374

7475
// newHandle creates a new Handle from a C handle (nullable) and a diagnostics object.

0 commit comments

Comments
 (0)