hrev47548 adds 1 changeset to branch 'master' old head: 1a6ec0014087f954f0876237056595dfcd18e25e new head: 807bd20a8f13854c2c198aba25a6f4036726832e overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=807bd20+%5E1a6ec00 ---------------------------------------------------------------------------- 807bd20: Allocate the default UrlContext as a BReferenceable BUrlContext now inherits BReferenceable to make it easier to handle the context lifespan. Make the default context an always-retained reference to match this. No functional change in normal conditions, however this avoids an assert when BReferenceable is built in debug mode. [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47548 Commit: 807bd20a8f13854c2c198aba25a6f4036726832e URL: http://cgit.haiku-os.org/haiku/commit/?id=807bd20 Author: Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> Date: Tue Jul 22 15:21:57 2014 UTC ---------------------------------------------------------------------------- 1 file changed, 8 insertions(+), 2 deletions(-) src/kits/network/libnetapi/UrlProtocolRoster.cpp | 10 ++++++++-- ---------------------------------------------------------------------------- diff --git a/src/kits/network/libnetapi/UrlProtocolRoster.cpp b/src/kits/network/libnetapi/UrlProtocolRoster.cpp index 17018bf..4b44c99 100644 --- a/src/kits/network/libnetapi/UrlProtocolRoster.cpp +++ b/src/kits/network/libnetapi/UrlProtocolRoster.cpp @@ -18,7 +18,7 @@ #include <UrlRequest.h> -static BUrlContext gDefaultContext; +static BReference<BUrlContext> gDefaultContext = new(std::nothrow) BUrlContext(); /* static */ BUrlRequest* @@ -26,7 +26,13 @@ BUrlProtocolRoster::MakeRequest(const BUrl& url, BUrlProtocolListener* listener, BUrlContext* context) { if (context == NULL) - context = &gDefaultContext; + context = gDefaultContext; + + if (context == NULL) { + // Allocation of the gDefaultContext failed. Don't allow creating + // requests without a context. + return NULL; + } // TODO: instanciate the correct BUrlProtocol using add-on interface if (url.Protocol() == "http") {