From 448781ba76da3d3d04f11659f7793e9829f2c580 Mon Sep 17 00:00:00 2001 From: itsToggle <71379623+itsToggle@users.noreply.github.com> Date: Thu, 20 Oct 2022 10:49:54 +0200 Subject: [PATCH] fix for memory panic when opening broken file --- backend/realdebrid/realdebrid.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/realdebrid/realdebrid.go b/backend/realdebrid/realdebrid.go index fcd3082630191..e330c50ec7d5f 100644 --- a/backend/realdebrid/realdebrid.go +++ b/backend/realdebrid/realdebrid.go @@ -1165,6 +1165,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read } fs.FixRangeOption(options, o.size) var resp *http.Response + var err_code = 0 opts := rest.Opts{ Path: "", RootURL: o.url, @@ -1173,10 +1174,13 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read } err = o.fs.pacer.Call(func() (bool, error) { resp, err = o.fs.srv.Call(ctx, &opts) + if resp != nil { + err_code = resp.StatusCode + } return shouldRetry(ctx, resp, err) }) if err != nil { - if resp.StatusCode == 503 { + if err_code == 503 { for _, TorrentID := range broken_torrents { if o.ParentID == TorrentID { return nil, err