From f57c82deba73faa59e85dcb1aa136de2d1a40664 Mon Sep 17 00:00:00 2001 From: Tulsi Shah <46474643+Tulsishah@users.noreply.github.com> Date: Tue, 26 Nov 2024 19:52:49 +0530 Subject: [PATCH] fix(gensupport): context cancel error check (#2890) Previously, if an rCtx wasn't created with chunkTransferTimeout and the parent context had a timeout, calling cancel under the same conditions caused a crash due to invalid memory access. This occurred if the parent context's timeout was triggered. --- internal/gensupport/resumable.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/gensupport/resumable.go b/internal/gensupport/resumable.go index 9e3bcf15963..a87fd3e727b 100644 --- a/internal/gensupport/resumable.go +++ b/internal/gensupport/resumable.go @@ -266,7 +266,7 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err // The upload should be retried if the rCtx is canceled due to a timeout. select { case <-rCtx.Done(): - if errors.Is(rCtx.Err(), context.DeadlineExceeded) { + if rx.ChunkTransferTimeout != 0 && errors.Is(rCtx.Err(), context.DeadlineExceeded) { // Cancel the context for rCtx cancel() continue