blackjack / webcam

Golang webcam library for Linux
MIT License
411 stars 90 forks source link

Webcam should prevent double close #56

Open edaniels opened 1 year ago

edaniels commented 1 year ago

In https://github.com/blackjack/webcam/blob/master/webcam.go#L276, a user may accidentally (due to a bug) call Close more than once. This is particularly dangerous since we're holding to a raw file descriptor number. This could play out as:

  1. First close (normal, expected)
  2. Some other code opens a file and gets that now unused file descriptor number
  3. Second close (bug, unexpected) and now the other code has its file descriptor unexpectedly modified