From ccf9f87e2ad37ddbd1f7bc6e5c0c7942b936bb49 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 5 Feb 2019 01:31:12 -0800 Subject: [PATCH] ircd::m::id: Fail boolean validators faster on empty id. --- ircd/m_id.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ircd/m_id.cc b/ircd/m_id.cc index d07419785..3f7056d68 100644 --- a/ircd/m_id.cc +++ b/ircd/m_id.cc @@ -674,6 +674,9 @@ ircd::m::valid(const id::sigil &sigil, const string_view &id) noexcept try { + if(empty(id)) + return false; + validate(sigil, id); return true; } @@ -697,7 +700,10 @@ noexcept try start + std::min(size(id), id::MAX_SIZE) }; - return id.at(0) == sigil && qi::parse(start, stop, test) && start == stop; + return !empty(id) && + id.at(0) == sigil && + qi::parse(start, stop, test) && + start == stop; } catch(...) { @@ -719,7 +725,9 @@ noexcept try start + std::min(size(id), id::MAX_SIZE) }; - return id.at(0) == sigil && qi::parse(start, stop, test); + return !empty(id) && + id.at(0) == sigil && + qi::parse(start, stop, test); } catch(...) {