From ca6b5b67d532459d3d679a92b225cd3944c8be88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 29 Nov 2013 12:21:02 +0100 Subject: [PATCH] Don't call a non-set callback. --- net/http_client.cpp | 2 +- net/http_client.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/http_client.cpp b/net/http_client.cpp index e76196302f..3c11e02cf6 100644 --- a/net/http_client.cpp +++ b/net/http_client.cpp @@ -314,7 +314,7 @@ void Download::SetFailed(int code) { void Download::Do(std::shared_ptr self) { // as long as this is in scope, we won't get destructed. // yeah this is ugly, I need to think about how life time should be managed for these... - std::shared_ptr self_ = self; + std::shared_ptr self_ = self; resultCode_ = 0; Url fileUrl(url_); diff --git a/net/http_client.h b/net/http_client.h index 94b8e67b88..bfd4ed0731 100644 --- a/net/http_client.h +++ b/net/http_client.h @@ -102,7 +102,9 @@ public: callback_ = callback; } void RunCallback() { - callback_(*this); + if (callback_) { + callback_(*this); + } } private: