Skip to content

Commit

Permalink
fix(gensupport): context cancel error check (#2890)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tulsishah authored Nov 26, 2024
1 parent f446504 commit f57c82d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/gensupport/resumable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f57c82d

Please sign in to comment.