Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: Source/core/css/CSSParserValues.cpp

Issue 277433002: MQParser memory leak fix (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Renamed clear to clearAndLeakValues Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSParserValues.h ('k') | Source/core/css/CSSParserValuesTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSParserValues.cpp
diff --git a/Source/core/css/CSSParserValues.cpp b/Source/core/css/CSSParserValues.cpp
index 484272de759de25a1b11febfb763ab2920198f03..86caffe35590e95f7b95135bd1030ef33633e1c3 100644
--- a/Source/core/css/CSSParserValues.cpp
+++ b/Source/core/css/CSSParserValues.cpp
@@ -29,17 +29,28 @@ namespace WebCore {
using namespace WTF;
-CSSParserValueList::~CSSParserValueList()
+static void destroy(Vector<CSSParserValue, 4>& values)
{
- size_t numValues = m_values.size();
+ size_t numValues = values.size();
for (size_t i = 0; i < numValues; i++) {
- if (m_values[i].unit == CSSParserValue::Function)
- delete m_values[i].function;
- else if (m_values[i].unit == CSSParserValue::ValueList)
- delete m_values[i].valueList;
+ if (values[i].unit == CSSParserValue::Function)
+ delete values[i].function;
+ else if (values[i].unit == CSSParserValue::ValueList)
+ delete values[i].valueList;
}
}
+void CSSParserValueList::destroyAndClear()
+{
+ destroy(m_values);
+ clearAndLeakValues();
+}
+
+CSSParserValueList::~CSSParserValueList()
+{
+ destroy(m_values);
+}
+
void CSSParserValueList::addValue(const CSSParserValue& v)
{
m_values.append(v);
@@ -54,7 +65,7 @@ void CSSParserValueList::stealValues(CSSParserValueList& valueList)
{
for (unsigned i = 0; i < valueList.size(); ++i)
m_values.append(*(valueList.valueAt(i)));
- valueList.clear();
+ valueList.clearAndLeakValues();
}
PassRefPtrWillBeRawPtr<CSSValue> CSSParserValue::createCSSValue()
« no previous file with comments | « Source/core/css/CSSParserValues.h ('k') | Source/core/css/CSSParserValuesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698