From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Wed, 20 Mar 2024 22:59:46 +0000 (+0000) Subject: NoNewGlobals for digestFieldsLookupTable (#1743) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=738f51a1b2be8e824dda030031175c0d47f452d6;p=thirdparty%2Fsquid.git NoNewGlobals for digestFieldsLookupTable (#1743) Detected by Coverity. CID 1554677: Initialization or destruction ordering is unspecified (GLOBAL_INIT_ORDER). --- diff --git a/src/auth/digest/Config.cc b/src/auth/digest/Config.cc index a3c9e93882..e00e15099b 100644 --- a/src/auth/digest/Config.cc +++ b/src/auth/digest/Config.cc @@ -66,22 +66,24 @@ enum http_digest_attr_type { DIGEST_INVALID_ATTR }; -static const LookupTable::Record -DigestAttrs[] = { - {"username", DIGEST_USERNAME}, - {"realm", DIGEST_REALM}, - {"qop", DIGEST_QOP}, - {"algorithm", DIGEST_ALGORITHM}, - {"uri", DIGEST_URI}, - {"nonce", DIGEST_NONCE}, - {"nc", DIGEST_NC}, - {"cnonce", DIGEST_CNONCE}, - {"response", DIGEST_RESPONSE}, - {nullptr, DIGEST_INVALID_ATTR} -}; - -LookupTable -DigestFieldsLookupTable(DIGEST_INVALID_ATTR, DigestAttrs); +static const auto & +digestFieldsLookupTable() +{ + static const LookupTable::Record DigestAttrs[] = { + {"username", DIGEST_USERNAME}, + {"realm", DIGEST_REALM}, + {"qop", DIGEST_QOP}, + {"algorithm", DIGEST_ALGORITHM}, + {"uri", DIGEST_URI}, + {"nonce", DIGEST_NONCE}, + {"nc", DIGEST_NC}, + {"cnonce", DIGEST_CNONCE}, + {"response", DIGEST_RESPONSE}, + {nullptr, DIGEST_INVALID_ATTR} + }; + static const auto table = new LookupTable(DIGEST_INVALID_ATTR, DigestAttrs); + return *table; +} /* * @@ -774,7 +776,7 @@ Auth::Digest::Config::decode(char const *proxy_auth, const HttpRequest *request, } /* find type */ - const http_digest_attr_type t = DigestFieldsLookupTable.lookup(keyName); + const auto t = digestFieldsLookupTable().lookup(keyName); switch (t) { case DIGEST_USERNAME: