aboutsummaryrefslogtreecommitdiff
path: root/cast/sender/public
diff options
context:
space:
mode:
authormark a. foltz <mfoltz@chromium.org>2020-11-06 17:34:15 -0800
committerCommit Bot <commit-bot@chromium.org>2020-11-09 18:02:46 +0000
commit1030c88a4bb869ab91ca5abf28471e50183f1bcb (patch)
tree354d9b3201d1778d0d1415a4f95b4861544916a3 /cast/sender/public
parent9abc1e30cfe55eab9360fe0a03bb06329f589b67 (diff)
downloadopenscreen-1030c88a4bb869ab91ca5abf28471e50183f1bcb.tar.gz
[Open Screen] Fix two unitialized reads dicovered by MSAN.
- Fix read of unitialized watch duration in OSP - Fix uninitialized endpoint_id in OSP Also, update Subscription to follow rule of 3/5, and simplify how query IDs are allocated in the cast_app_discovery_service. Bug: chromium:1143946 Change-Id: I78f3dd630626eaf47930d8a5c9bfdc3d05b49fb6 Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2511074 Commit-Queue: mark a. foltz <mfoltz@chromium.org> Reviewed-by: Brandon Tolsch <btolsch@chromium.org>
Diffstat (limited to 'cast/sender/public')
-rw-r--r--cast/sender/public/cast_app_discovery_service.cc14
-rw-r--r--cast/sender/public/cast_app_discovery_service.h15
2 files changed, 12 insertions, 17 deletions
diff --git a/cast/sender/public/cast_app_discovery_service.cc b/cast/sender/public/cast_app_discovery_service.cc
index c561b386..8299aff4 100644
--- a/cast/sender/public/cast_app_discovery_service.cc
+++ b/cast/sender/public/cast_app_discovery_service.cc
@@ -17,14 +17,16 @@ CastAppDiscoveryService::Subscription::Subscription(Subscription&& other)
other.discovery_service_ = nullptr;
}
-CastAppDiscoveryService::Subscription::~Subscription() {
- Reset();
+CastAppDiscoveryService::Subscription&
+CastAppDiscoveryService::Subscription::operator=(Subscription&& other) {
+ id_ = other.id_;
+ discovery_service_ = other.discovery_service_;
+ other.discovery_service_ = nullptr;
+ return *this;
}
-CastAppDiscoveryService::Subscription& CastAppDiscoveryService::Subscription::
-operator=(Subscription other) {
- Swap(other);
- return *this;
+CastAppDiscoveryService::Subscription::~Subscription() {
+ Reset();
}
void CastAppDiscoveryService::Subscription::Reset() {
diff --git a/cast/sender/public/cast_app_discovery_service.h b/cast/sender/public/cast_app_discovery_service.h
index ccb586ff..6ce5ee78 100644
--- a/cast/sender/public/cast_app_discovery_service.h
+++ b/cast/sender/public/cast_app_discovery_service.h
@@ -23,17 +23,18 @@ class CastAppDiscoveryService {
class Subscription {
public:
+ Subscription(CastAppDiscoveryService* discovery_service, uint32_t id);
Subscription(Subscription&&);
+ Subscription(Subscription&) = delete;
+ Subscription& operator=(Subscription&&);
+ Subscription& operator=(const Subscription&) = delete;
~Subscription();
- Subscription& operator=(Subscription);
void Reset();
private:
friend class CastAppDiscoveryService;
- Subscription(CastAppDiscoveryService* discovery_service, uint32_t id);
-
void Swap(Subscription& other);
CastAppDiscoveryService* discovery_service_;
@@ -57,15 +58,7 @@ class CastAppDiscoveryService {
// this method when the user initiates a user gesture.
virtual void Refresh() = 0;
- protected:
- Subscription MakeSubscription(CastAppDiscoveryService* discovery_service,
- uint32_t id) {
- return Subscription(discovery_service, id);
- }
-
private:
- friend class Subscription;
-
virtual void RemoveAvailabilityCallback(uint32_t id) = 0;
};