python: Fix python plugins that implement URIHandler

Ensure the generated URI strv list is NULL terminated in the python
binding

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5187>
This commit is contained in:
Jan Schmidt 2023-08-15 14:23:22 +10:00 committed by GStreamer Marge Bot
parent bc06c2109c
commit 627a956768

View file

@ -1131,11 +1131,11 @@ py_uri_handler_get_protocols_from_pyobject (PyObject * protocols)
len = PyTuple_Size (protocols); len = PyTuple_Size (protocols);
if (len == 0) { if (len == 0) {
PyErr_Format (PyExc_TypeError, PyErr_Format (PyExc_TypeError,
"Empty tuple for GstUriHandler.__protocols"); "Empty tuple for GstUriHandler.__protocols__");
goto err; goto err;
} }
res = g_malloc (len * sizeof (gchar *)); res = g_malloc0 ((len + 1) * sizeof (gchar *));
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
PyObject *protocol = (PyObject *) PyTuple_GetItem (protocols, i); PyObject *protocol = (PyObject *) PyTuple_GetItem (protocols, i);
@ -1147,8 +1147,8 @@ py_uri_handler_get_protocols_from_pyobject (PyObject * protocols)
res[i] = g_strdup (PyUnicode_AsUTF8 (protocol)); res[i] = g_strdup (PyUnicode_AsUTF8 (protocol));
} }
} else { } else {
PyErr_Format (PyExc_TypeError, "invalid type for GstUriHandler.__protocols." PyErr_Format (PyExc_TypeError,
" Should be a tuple"); "invalid type for GstUriHandler.__protocols__" " Should be a tuple");
goto err; goto err;
} }