gstreamer: Add error checking in gst_libcamera_src_task_enter()
The return value from generateConfiguration() was not checked. Only assert was added as a guard which checked if the size of the generated camera config was equal to size of roles passed to it. If the roles variable has an invalid/unsupported role, it will return a nullptr and then trying to access a member on a nullptr for size comparison will result in a segmentation fault. So, if the function returns a nullptr, simply push an error message on GstBus and gracefully exit. Signed-off-by: Vedant Paranjape <vedantparanjape160201@gmail.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
This commit is contained in:
parent
abdb11d9cc
commit
1e5cee7017
1 changed files with 7 additions and 4 deletions
|
@ -375,10 +375,13 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,
|
||||||
|
|
||||||
/* Generate the stream configurations, there should be one per pad. */
|
/* Generate the stream configurations, there should be one per pad. */
|
||||||
state->config_ = state->cam_->generateConfiguration(roles);
|
state->config_ = state->cam_->generateConfiguration(roles);
|
||||||
/*
|
if (state->config_ == nullptr) {
|
||||||
* \todo Check if camera may increase or decrease the number of streams
|
GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,
|
||||||
* regardless of the number of roles.
|
("Failed to generate camera configuration from roles"),
|
||||||
*/
|
("Camera::generateConfiguration() returned nullptr"));
|
||||||
|
gst_task_stop(task);
|
||||||
|
return;
|
||||||
|
}
|
||||||
g_assert(state->config_->size() == state->srcpads_.size());
|
g_assert(state->config_->size() == state->srcpads_.size());
|
||||||
|
|
||||||
for (gsize i = 0; i < state->srcpads_.size(); i++) {
|
for (gsize i = 0; i < state->srcpads_.size(); i++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue