Fix memory leak when removing CommandInstance from CommandQueue The observers for CommandInstance were forcefully cleared in CommandInstance::DetachFromQueue which caused failure of invoking CommandInstance::Observer::OnCommandDestroyed() and, as a result, CloudCommandProxy::OnCommandDestroyed was not called which caused leaking CloudCommandProxy object instance. BUG: 25707196 Change-Id: I119a67efce4968ffaa528632e77045265b8e8f2b Reviewed-on: https://weave-review.googlesource.com/2428 Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/src/commands/command_instance.h b/src/commands/command_instance.h index b1028d0..febe5c5 100644 --- a/src/commands/command_instance.h +++ b/src/commands/command_instance.h
@@ -89,10 +89,7 @@ // Sets the pointer to queue this command is part of. void AttachToQueue(CommandQueue* queue) { queue_ = queue; } - void DetachFromQueue() { - observers_.Clear(); - queue_ = nullptr; - } + void DetachFromQueue() { queue_ = nullptr; } private: // Helper function to update the command status.