mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-22 19:33:32 +02:00
Fix memory leak caused by requiring component.
This commit is contained in:
parent
00c4b6f44f
commit
3bfd6853f4
1 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue