From d67fc14d085849a6b0418bb3e912fea2e94c18d1 Mon Sep 17 00:00:00 2001
From: "Alexander V. Lukyanov" <lavv17f@gmail.com>
Date: Sat, 28 Nov 2020 20:09:11 +0300
Subject: [PATCH] fix a coredump in TorrentTracker (fix #513)

Conflict: NA
Reference: https://github.com/lavv17/lftp/commit/d67fc14d085849a6b0418bb3e912fea2e94c18d1
---
 src/TorrentTracker.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/TorrentTracker.cc b/src/TorrentTracker.cc
index f867c334..30b531ce 100644
--- a/src/TorrentTracker.cc
+++ b/src/TorrentTracker.cc
@@ -121,7 +121,7 @@ bool TorrentTracker::AddPeer(const xstring& addr,int port) const
 int TorrentTracker::Do()
 {
    int m=STALL;
-   if(Failed())
+   if(Failed() || !backend)
       return m;
    if(backend && backend->IsActive()) {
       if(tracker_timeout_timer.Stopped()) {
@@ -165,6 +165,8 @@ void TorrentTracker::Start()
 }
 void TorrentTracker::SendTrackerRequest(const char *event)
 {
+   if(!backend)
+      return;
    backend->SendTrackerRequest(event);
    tracker_timeout_timer.Reset();
 }
