From 38306b389951c69d050e3e4b929b442b5bd0ada5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 17 Feb 2016 04:40:53 +0100 Subject: tracker/pt: protect get_n_points() There's a race here since further accesses to the points array aren't protected by a mutex in the extractor class. There's no race in "get_points()" in the extractor since it's only used in same thread where updates take place. --- tracker-pt/ftnoir_tracker_pt.h | 2 +- tracker-pt/point_extractor.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'tracker-pt') diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index dff0c30a..5f30c66f 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -41,7 +41,7 @@ public: void data(double* data) override; Affine pose() { return point_tracker.pose(); } - int get_n_points() { return point_extractor.get_points().size(); } + int get_n_points() { return point_extractor.get_n_points(); } bool get_cam_info(CamInfo* info) { QMutexLocker lock(&camera_mtx); return camera.get_info(*info); } public slots: void apply_settings(); diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h index 030251ff..8bcc2437 100644 --- a/tracker-pt/point_extractor.h +++ b/tracker-pt/point_extractor.h @@ -23,6 +23,7 @@ public: // WARNING: returned reference is valid as long as object const std::vector &extract_points(cv::Mat &frame); const std::vector& get_points() { QMutexLocker l(&mtx); return points; } + int get_n_points() const { QMutexLocker l(&mtx); return points.size(); } PointExtractor(); settings_pt s; -- cgit v1.2.3