Skip to content

Commit 0a27537

Browse files
committed
Fix segfault when passing non-string into Windows camera
Now says "TypeError: bad argument type for built-in operation".
1 parent d6bb083 commit 0a27537

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src_c/_camera.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,9 @@ camera_init(pgCameraObject *self, PyObject *arg, PyObject *kwargs)
18861886

18871887
/* needs to be freed with PyMem_Free later */
18881888
dev_name = PyUnicode_AsWideCharString(name_obj, NULL);
1889+
if (dev_name == NULL) {
1890+
return -1;
1891+
}
18891892

18901893
p = windows_device_from_name(dev_name);
18911894

0 commit comments

Comments
 (0)