webcam icon indicating copy to clipboard operation
webcam copied to clipboard

Webcam should prevent double close

Open edaniels opened this issue 2 years ago • 0 comments

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

edaniels avatar Feb 16 '23 19:02 edaniels