From 3bfd6853f4c0e6ac98c0243b28ad3eb376fc346f Mon Sep 17 00:00:00 2001 From: pocketW <104479902+pocketW@users.noreply.github.com> Date: Thu, 28 Apr 2022 14:22:05 +1000 Subject: [PATCH] Fix memory leak caused by requiring component. --- app/dispatcher/fakednssniffer.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/dispatcher/fakednssniffer.go b/app/dispatcher/fakednssniffer.go index 2275e502..ad057fe8 100644 --- a/app/dispatcher/fakednssniffer.go +++ b/app/dispatcher/fakednssniffer.go @@ -14,12 +14,13 @@ import ( // newFakeDNSSniffer Creates a Fake DNS metadata sniffer func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) { var fakeDNSEngine dns.FakeDNSEngine - err := core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { - fakeDNSEngine = fdns - }) - if err != nil { - return protocolSnifferWithMetadata{}, err + { + fakeDNSEngineFeat := core.MustFromContext(ctx).GetFeature(fakeDNSEngine) + if fakeDNSEngineFeat != nil { + fakeDNSEngine = fakeDNSEngineFeat.(dns.FakeDNSEngine) + } } + if fakeDNSEngine == nil { errNotInit := newError("FakeDNSEngine is not initialized, but such a sniffer is used").AtError() return protocolSnifferWithMetadata{}, errNotInit