gstreamer: Do not lookup controls by id

The libcamerasrc element looks for the availability of the
FrameDurationLimits control by looking it up by numeric control id.

The ControlinfoMap::find(unsigned int i) function searches the control
numerical identifier on the ContorlInfoMap::idMap_ class member, which
might be not initialized if the pipeline handler does not register
any control, causing an invalid memory access.

Avoid looking up the control by numerical id and use the ControlId
instance instead to prevent that.

Fixes: ccfe0a1af7 ("gstreamer: Provide framerate support for libcamerasrc")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi 2022-11-18 17:14:14 +01:00
parent 40f338be67
commit e228a5b7f4

View file

@ -436,7 +436,7 @@ void gst_libcamera_clamp_and_set_frameduration(ControlList &initCtrls,
if (!gst_structure_has_field_typed(element_caps, "framerate", GST_TYPE_FRACTION)) if (!gst_structure_has_field_typed(element_caps, "framerate", GST_TYPE_FRACTION))
return; return;
auto iterFrameDuration = cam_ctrls.find(controls::FrameDurationLimits.id()); auto iterFrameDuration = cam_ctrls.find(&controls::FrameDurationLimits);
if (iterFrameDuration == cam_ctrls.end()) { if (iterFrameDuration == cam_ctrls.end()) {
GST_WARNING("FrameDurationLimits not found in camera controls."); GST_WARNING("FrameDurationLimits not found in camera controls.");
return; return;