Changeset 57626 in webkit


Ignore:
Timestamp:
Apr 14, 2010 8:07:49 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-14 Jedrzej Nowacki <jedrzej.nowacki@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

Fix a few memory leaks in QScriptEngine.

Syntax checking caused memory leak, not all temporary variables were released.

[Qt] Syntax checking in the QtScript cause a memory leak.
https://bugs.webkit.org/show_bug.cgi?id=37610

  • qt/api/qscriptengine_p.cpp: (QScriptEnginePrivate::checkSyntax):
  • qt/api/qscriptsyntaxcheckresult.cpp: (QScriptSyntaxCheckResultPrivate::errorMessage): (QScriptSyntaxCheckResultPrivate::errorLineNumber):
Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r57625 r57626  
     12010-04-14  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        Fix a few memory leaks in QScriptEngine.
     6
     7        Syntax checking caused memory leak, not all temporary variables were released.
     8
     9        [Qt] Syntax checking  in the QtScript cause a memory leak.
     10        https://bugs.webkit.org/show_bug.cgi?id=37610
     11
     12        * qt/api/qscriptengine_p.cpp:
     13        (QScriptEnginePrivate::checkSyntax):
     14        * qt/api/qscriptsyntaxcheckresult.cpp:
     15        (QScriptSyntaxCheckResultPrivate::errorMessage):
     16        (QScriptSyntaxCheckResultPrivate::errorLineNumber):
     17
    1182010-04-14  Jedrzej Nowacki  <jedrzej.nowacki@nokia.com>
    219
  • trunk/JavaScriptCore/qt/api/qscriptengine_p.cpp

    r56686 r57626  
    4343{
    4444    JSValueRef exception;
    45     if (JSCheckScriptSyntax(m_context, QScriptConverter::toString(program), /* url */ 0, /* starting line */ 1, &exception))
     45    JSStringRef source = QScriptConverter::toString(program);
     46    bool syntaxIsCorrect = JSCheckScriptSyntax(m_context, source, /* url */ 0, /* starting line */ 1, &exception);
     47    JSStringRelease(source);
     48    if (syntaxIsCorrect) {
    4649        return new QScriptSyntaxCheckResultPrivate(this);
     50    }
    4751    JSValueProtect(m_context, exception);
    4852    return new QScriptSyntaxCheckResultPrivate(this, const_cast<JSObjectRef>(exception));
  • trunk/JavaScriptCore/qt/api/qscriptsyntaxcheckresult.cpp

    r56333 r57626  
    125125QString QScriptSyntaxCheckResultPrivate::errorMessage() const
    126126{
    127     if (m_exception)
    128         return QScriptConverter::toString(JSValueToStringCopy(m_engine->context(), m_exception, /* exception */ 0));
    129     return QString();
     127    if (!m_exception)
     128        return QString();
     129
     130    JSStringRef tmp = JSValueToStringCopy(m_engine->context(), m_exception, /* exception */ 0);
     131    QString message = QScriptConverter::toString(tmp);
     132    JSStringRelease(tmp);
     133    return message;
    130134}
    131135
     
    135139        return -1;
    136140    // m_exception is an instance of the Exception so it has "line" attribute.
     141    JSStringRef lineAttrName = QScriptConverter::toString("line");
    137142    JSValueRef line = JSObjectGetProperty(m_engine->context(),
    138143                                          m_exception,
    139                                           QScriptConverter::toString("line"),
     144                                          lineAttrName,
    140145                                          /* exceptions */0);
     146    JSStringRelease(lineAttrName);
    141147    return JSValueToNumber(m_engine->context(), line, /* exceptions */0);
    142148}
Note: See TracChangeset for help on using the changeset viewer.