Skip to content

Commit 7f93f8c

Browse files
committed
Fix deallocation bug which causes Python to exit/crash if the device fails to load. See jnohlgard#13
1 parent dc09a8c commit 7f93f8c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

v4l2capture.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,14 @@ static int Video_device_init(Video_device *self, PyObject *args,
133133
return -1;
134134
}
135135

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

138-
if(fd < 0)
138+
if(self->fd < 0)
139139
{
140140
PyErr_SetFromErrnoWithFilename(PyExc_IOError, (char *)device_path);
141141
return -1;
142142
}
143143

144-
self->fd = fd;
145144
self->buffers = NULL;
146145
return 0;
147146
}

0 commit comments

Comments
 (0)