From 5511fa441a57a0c662558d92bfa7bf0eda4f1b66 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Wed, 19 Jun 2024 20:06:40 +0100 Subject: [PATCH] onedrive: fix nil pointer error when uploading small files Before this fix when uploading a single part file, if the o.fetchAndUpdateMetadata() call failed rclone would call o.setMetaData() with a nil info which caused a crash. This fixes the problem by returning the error from o.fetchAndUpdateMetadata() explicitly. See: https://forum.rclone.org/t/serve-webdav-is-crashing-fatal-error-sync-unlock-of-unlocked-mutex/46300 --- backend/onedrive/onedrive.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backend/onedrive/onedrive.go b/backend/onedrive/onedrive.go index 1ac8090de..abdffdf1c 100644 --- a/backend/onedrive/onedrive.go +++ b/backend/onedrive/onedrive.go @@ -2538,6 +2538,9 @@ func (o *Object) uploadSinglepart(ctx context.Context, in io.Reader, src fs.Obje } // Set the mod time now and read metadata info, err = o.fs.fetchAndUpdateMetadata(ctx, src, options, o) + if err != nil { + return nil, fmt.Errorf("failed to fetch and update metadata: %w", err) + } return info, o.setMetaData(info) }