Skip to content

Instantly share code, notes, and snippets.

@abarth
Created November 29, 2016 18:38
Show Gist options
  • Save abarth/a534d4c1829774f3222832d681e4c9b2 to your computer and use it in GitHub Desktop.
Save abarth/a534d4c1829774f3222832d681e4c9b2 to your computer and use it in GitHub Desktop.
diff --git a/src/suggestion_engine/suggestion_agent_client_impl.cc b/src/suggestion_engine/suggestion_agent_client_impl.cc
index e731435..fa0f23d 100644
--- a/src/suggestion_engine/suggestion_agent_client_impl.cc
+++ b/src/suggestion_engine/suggestion_agent_client_impl.cc
@@ -26,8 +26,10 @@ void SuggestionAgentClientImpl::Remove(const fidl::String& proposal_id) {
channel_rank.first->OnRemoveSuggestion(channel_rank.second);
}
- repo_->RemoveSuggestion(record->second.suggestion_prototype->first);
- proposals_.erase(record);
+ if (record->second.suggestion_prototype) {
+ repo_->RemoveSuggestion(record->second.suggestion_prototype->first);
+ proposals_.erase(record);
+ }
if (ShouldEraseSelf())
EraseSelf();
@@ -56,7 +58,9 @@ void SuggestionAgentClientImpl::OnChangeProposal(
AgentSuggestionRecord* record) {
// TODO(rosswang): dedup
- record->suggestion_prototype->second->proposal = std::move(proposal);
+ if (record->suggestion_prototype && record->suggestion_prototype->second) {
+ record->suggestion_prototype->second->proposal = std::move(proposal);
+ }
for (auto& channel_rank : record->ranks_by_channel) {
channel_rank.first->OnChangeSuggestion(channel_rank.second);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment