summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVedant Paranjape <vedantparanjape160201@gmail.com>2021-06-02 19:41:38 +0530
committerPaul Elder <paul.elder@ideasonboard.com>2021-06-07 14:06:50 +0900
commit1e5cee701781276fb03f18e704a5a6ea8f24eff8 (patch)
tree49a0459ff186b3d54f4ba25d34a0ed33b722eb68 /src
parentabdb11d9ccad4cf0f566b826d7068e67d5800388 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gstreamer/gstlibcamerasrc.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 87246b40..ccc61590 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -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. */
state->config_ = state->cam_->generateConfiguration(roles);
- /*
- * \todo Check if camera may increase or decrease the number of streams
- * regardless of the number of roles.
- */
+ if (state->config_ == nullptr) {
+ GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,
+ ("Failed to generate camera configuration from roles"),
+ ("Camera::generateConfiguration() returned nullptr"));
+ gst_task_stop(task);
+ return;
+ }
g_assert(state->config_->size() == state->srcpads_.size());
for (gsize i = 0; i < state->srcpads_.size(); i++) {