Commit 98d0f30c by Lingfeng Yang Committed by Commit Bot

Add to names map even if it's a prefixed name

Previously, we skipped adding to the names map if it was a prefixed name. This prevents the mapping of glsl es to glsl names from being accessible by an outside client. Bug: b/158533223 Change-Id: Ib1d1e229ceb6d836df8dd0c30ea848b081a40cad Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2240637Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarLingfeng Yang <lfy@google.com> Commit-Queue: Lingfeng Yang <lfy@google.com>
parent af727792
......@@ -36,6 +36,22 @@ ImmutableString HashName(const ImmutableString &name, ShHashFunction64 hashFunct
return hashedName;
}
void AddToNameMapIfNotMapped(const ImmutableString &name,
const ImmutableString &hashedName,
NameMap *nameMap)
{
if (nameMap)
{
NameMap::const_iterator it = nameMap->find(name.data());
if (it != nameMap->end())
{
// (How bout returning?)
return;
}
(*nameMap)[name.data()] = hashedName.data();
}
}
} // anonymous namespace
ImmutableString HashName(const ImmutableString &name,
......@@ -84,22 +100,14 @@ ImmutableString HashName(const ImmutableString &name,
}
ImmutableStringBuilder prefixedName(kUnhashedNamePrefix.length() + name.length());
prefixedName << kUnhashedNamePrefix << name;
return prefixedName;
}
if (nameMap)
{
NameMap::const_iterator it = nameMap->find(name.data());
if (it != nameMap->end())
{
// TODO(oetuaho): Would be nice if we didn't need to allocate a string here.
return ImmutableString(it->second);
}
ImmutableString res = prefixedName;
AddToNameMapIfNotMapped(name, res, nameMap);
return res;
}
// Has a hash function
ImmutableString hashedName = HashName(name, hashFunction);
if (nameMap)
{
(*nameMap)[name.data()] = hashedName.data();
}
AddToNameMapIfNotMapped(name, hashedName, nameMap);
return hashedName;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment