Skip to content

Commit

Permalink
Fix deallocation bug which causes Python to exit/crash if the device …
Browse files Browse the repository at this point in the history
…fails to load. See jnohlgard#13
  • Loading branch information
jcoffland committed Sep 15, 2018
1 parent dc09a8c commit 7f93f8c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions v4l2capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,14 @@ static int Video_device_init(Video_device *self, PyObject *args,
return -1;
}

int fd = v4l2_open(device_path, O_RDWR | O_NONBLOCK);
self->fd = v4l2_open(device_path, O_RDWR | O_NONBLOCK);

if(fd < 0)
if(self->fd < 0)
{
PyErr_SetFromErrnoWithFilename(PyExc_IOError, (char *)device_path);
return -1;
}

self->fd = fd;
self->buffers = NULL;
return 0;
}
Expand Down

0 comments on commit 7f93f8c

Please sign in to comment.