From 87f0d169bf16bf4e76f843e240b15dd21841e724 Mon Sep 17 00:00:00 2001 From: Sebastian Hahta <joseha@utu.fi> Date: Tue, 16 Jun 2020 15:21:17 +0300 Subject: [PATCH] nullptr bugs --- components/common/cpp/include/ftl/configuration.hpp | 9 +++++---- components/common/cpp/src/uri.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/components/common/cpp/include/ftl/configuration.hpp b/components/common/cpp/include/ftl/configuration.hpp index bdbc4a590..ec8357155 100644 --- a/components/common/cpp/include/ftl/configuration.hpp +++ b/components/common/cpp/include/ftl/configuration.hpp @@ -172,11 +172,12 @@ T *ftl::config::create(json_t &link, ARGS ...args) { cfg->patchPtr(link); } - try { - return dynamic_cast<T*>(cfg); - } catch(...) { + T* ptr = dynamic_cast<T*>(cfg); + if (ptr) { + return ptr + } + else { throw FTL_Error("Configuration URI object is of wrong type: " << id); - //return nullptr; } } diff --git a/components/common/cpp/src/uri.cpp b/components/common/cpp/src/uri.cpp index fa059a0a8..71b6e195d 100644 --- a/components/common/cpp/src/uri.cpp +++ b/components/common/cpp/src/uri.cpp @@ -72,7 +72,7 @@ void URI::_parse(uri_t puri) { m_frag = ""; } else { m_host = std::string(uri.hostText.first, uri.hostText.afterLast - uri.hostText.first); - + std::string prototext = std::string(uri.scheme.first, uri.scheme.afterLast - uri.scheme.first); if (prototext == "tcp") m_proto = SCHEME_TCP; else if (prototext == "udp") m_proto = SCHEME_UDP; @@ -106,7 +106,7 @@ void URI::_parse(uri_t puri) { uri.query.afterLast) != URI_SUCCESS) { // Failure } - + UriQueryListA *item = queryList; while (item) { m_qmap[item->key] = item->value; @@ -140,9 +140,12 @@ void URI::_parse(uri_t puri) { else if (uri.fragment.first != NULL) { m_base += std::string(start, uri.fragment.first - start - 1); } - else { + else if (start) { m_base += std::string(start); } + else { + m_base += std::string(""); + } } } } -- GitLab