From 1da9776adb7a195a2bd4f0c437bdf72f8bf2ea69 Mon Sep 17 00:00:00 2001 From: Yaroslav Kirillov Date: Thu, 12 Dec 2024 16:01:34 +0500 Subject: [PATCH] Fix decode plugin with protobuf decoder (#721) --- plugin/action/decode/decode.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugin/action/decode/decode.go b/plugin/action/decode/decode.go index f7ed5a4c..da57e00b 100644 --- a/plugin/action/decode/decode.go +++ b/plugin/action/decode/decode.go @@ -543,10 +543,11 @@ func (p *Plugin) decodeNginxError(root *insaneJSON.Root, node *insaneJSON.Node) } func (p *Plugin) decodeProtobuf(root *insaneJSON.Root, node *insaneJSON.Node, buf []byte) { - t := insaneJSON.Spawn() - defer insaneJSON.Release(t) - - err := p.decoder.DecodeToJson(t, node.AsBytes()) + jsonRaw, err := p.decoder.Decode(node.AsBytes()) + if p.checkError(err, node) { + return + } + t, err := root.DecodeBytesAdditional(jsonRaw.([]byte)) if p.checkError(err, node) { return } @@ -565,7 +566,7 @@ func (p *Plugin) decodeProtobuf(root *insaneJSON.Root, node *insaneJSON.Node, bu node.Suicide() } - root.MergeWith(t.Node) + root.MergeWith(t) } func (p *Plugin) addFieldPrefix(root *insaneJSON.Root, key string, val []byte) {