Commit 9092bdc7 by Ian Elliott Committed by Commit Bot

Fix crash in A4A opt-in/out logic.

The Device::match() method used to call the old ListOf<T>::match() method with ListOf<T>::front(), assuming that front() always returned a valid object reference. It did not (e.g. the default rule had a wildcarded device that had no GPU). A new ListOf<T>::match() was created (for the GPU case) that compares to ListOf<T> objects. If either/both is wildcarded, true is quickly returned. If both are not wildcarded, they will have one or more T's, and these are iterated through (one in the new method, and one by calling the old method). During rule processing, it is safe to directly call the old method for a Rule's ListOf<{Device|Application}>, and so the old method is retained. Change-Id: Iea47075c38dc45eb32e1810c4997b8cfb2fe9ec3 Reviewed-on: https://chromium-review.googlesource.com/c/1365678 Commit-Queue: Ian Elliott <ianelliott@google.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d300548f
......@@ -186,7 +186,24 @@ class ListOf
}
return false;
}
const T &front() const { return (mList.front()); }
bool match(const ListOf<T> &toCheck) const
{
VERBOSE("\t\t Within ListOf<%s> match: wildcards are %s and %s,\n", mListType.c_str(),
mWildcard ? "true" : "false", toCheck.mWildcard ? "true" : "false");
if (mWildcard || toCheck.mWildcard)
{
return true;
}
// If we make it to here, both this and toCheck have at least one item in their mList
for (const T &it : toCheck.mList)
{
if (match(it))
{
return true;
}
}
return false;
}
void logListOf(const std::string prefix, const std::string name) const
{
if (mWildcard)
......@@ -561,9 +578,7 @@ class Device
return ((mWildcard || toCheck.mWildcard ||
// The wildcards can override the Manufacturer/Model check, but not the GPU check
(toCheck.mManufacturer.match(mManufacturer) && toCheck.mModel.match(mModel))) &&
// Note: toCheck.mGpuList is for the device and must contain exactly one item,
// where mGpuList may contain zero or more items:
mGpuList.match(toCheck.mGpuList.front()));
mGpuList.match(toCheck.mGpuList));
}
void logItem() const
{
......
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