Commit 4e37aa45 authored by yoav@yoav.ws's avatar yoav@yoav.ws

Fix an MQ parsing related crash

When MediaQueryParser used valuesList.clear(), clear() cleared the list's values, but not the offset of the current read value.
This fixes that.

BUG=353982

Review URL: https://codereview.chromium.org/204333005

git-svn-id: svn://svn.chromium.org/blink/trunk@169630 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8d7cec02
......@@ -194,7 +194,7 @@ public:
CSSParserValue* valueAt(unsigned i) { return i < m_values.size() ? &m_values[i] : 0; }
void clear() { m_values.clear(); }
void clear() { m_values.clear(); m_current = 0;}
private:
unsigned m_current;
......
......@@ -84,4 +84,17 @@ TEST(CSSParserValuesTest, EqualIgnoringCase16BitsString)
ASSERT_FALSE(cssParserString.equalIgnoringCase("abCD"));
}
TEST(CSSParserValuesTest, CSSParserValuelistClear)
{
CSSParserValueList list;
for (int i = 0; i < 3; ++i) {
CSSParserValue value;
value.setFromNumber(3);
list.addValue(value);
}
list.clear();
ASSERT_FALSE(list.size());
ASSERT_FALSE(list.currentIndex());
}
} // namespace
......@@ -214,6 +214,8 @@ MediaQueryExp::MediaQueryExp(const String& mediaFeature, PassRefPtrWillBeRawPtr<
// FIXME - create should not return a null.
PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const String& mediaFeature, CSSParserValueList* valueList)
{
ASSERT(!mediaFeature.isNull());
RefPtrWillBeRawPtr<CSSValue> cssValue;
bool isValid = false;
String lowerMediaFeature = attemptStaticStringCreation(mediaFeature.lower());
......@@ -222,6 +224,7 @@ PassOwnPtrWillBeRawPtr<MediaQueryExp> MediaQueryExp::create(const String& mediaF
if (valueList && valueList->size() > 0) {
if (valueList->size() == 1) {
CSSParserValue* value = valueList->current();
ASSERT(value);
if (featureWithCSSValueID(lowerMediaFeature, value)) {
// Media features that use CSSValueIDs.
......
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