Skip to content

Commit f57c82d

Browse files
authored
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.
1 parent f446504 commit f57c82d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎internal/gensupport/resumable.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
266266
// The upload should be retried if the rCtx is canceled due to a timeout.
267267
select {
268268
case <-rCtx.Done():
269-
if errors.Is(rCtx.Err(), context.DeadlineExceeded) {
269+
if rx.ChunkTransferTimeout != 0 && errors.Is(rCtx.Err(), context.DeadlineExceeded) {
270270
// Cancel the context for rCtx
271271
cancel()
272272
continue

0 commit comments

Comments
 (0)