Skip to content

Commit

Permalink
fix crash when context is cancelled when creating gif
Browse files Browse the repository at this point in the history
Semaphore acquisition will still succeed without modifying the semaphore
itself when the context is cancelled. This creates a situation where it
is possible to release more semaphores than held.
  • Loading branch information
hizkifw committed Mar 16, 2024
1 parent 0a06668 commit c5773d5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ func (f *Ffmpeg) MakeGifThumbnail(ctx context.Context, videoUrl string, outputFi
}
defer f.doneProcessing(videoUrl)

// Disconnect from the context
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

// Create temporary directory
workdir, err := os.MkdirTemp("", "thumb-")
if err != nil {
Expand Down

0 comments on commit c5773d5

Please sign in to comment.