mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
v4l2src: fix memory leak in new uri handler code
Don't leak a string everytime get_uri() is called and a device has been set. There's a limited number of devices, so just intern the string instead of doing more elaborate housekeeping and storing it in the instance struct or so.
This commit is contained in:
parent
fd9530d2d5
commit
d68689255d
1 changed files with 10 additions and 2 deletions
|
@ -982,8 +982,16 @@ gst_v4l2src_uri_get_uri (GstURIHandler * handler)
|
|||
{
|
||||
GstV4l2Src *v4l2src = GST_V4L2SRC (handler);
|
||||
|
||||
if (v4l2src->v4l2object->videodev)
|
||||
return g_strdup_printf ("v4l2://%s", v4l2src->v4l2object->videodev);
|
||||
if (v4l2src->v4l2object->videodev != NULL) {
|
||||
gchar uri[256];
|
||||
|
||||
/* need to return a const string, but also don't want to leak the generated
|
||||
* string, so just intern it - there's a limited number of video devices
|
||||
* after all */
|
||||
g_snprintf (uri, sizeof (uri), "v4l2://%s", v4l2src->v4l2object->videodev);
|
||||
return g_intern_string (uri);
|
||||
}
|
||||
|
||||
return "v4l2://";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue