RESOLVED FIXED 34573
[Qt] layoutTestController.counterValueForElementById crashes for a nonexistent ID
https://bugs.webkit.org/show_bug.cgi?id=34573
Summary [Qt] layoutTestController.counterValueForElementById crashes for a nonexisten...
Shinichiro Hamaji
Reported 2010-02-04 04:00:19 PST
This was added in Bug 33840.
Attachments
Patch v1 (5.63 KB, patch)
2010-02-04 04:42 PST, Shinichiro Hamaji
hausmann: review+
Shinichiro Hamaji
Comment 1 2010-02-04 04:42:19 PST
Created attachment 48133 [details] Patch v1
Shinichiro Hamaji
Comment 2 2010-02-04 04:46:40 PST
Comment on attachment 48133 [details] Patch v1 > diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp > index aeb7a22..bc00f1b 100644 > --- a/WebKit/qt/Api/qwebframe.cpp > +++ b/WebKit/qt/Api/qwebframe.cpp > @@ -214,12 +214,23 @@ QString QWEBKIT_EXPORT qt_drt_counterValueForElementById(QWebFrame* qFrame, cons > { > Frame* frame = QWebFramePrivate::core(qFrame); > if (Document* document = frame->document()) { > - Element* element = document->getElementById(id); > - return WebCore::counterValueForElement(element); > + if (Element* element = document->getElementById(id)) > + return WebCore::counterValueForElement(element); This change is not related to this change, but I think it's small enough to fix with the main change. This change avoids crash when a nonexistent element ID is specified. If a reviewer considers this should be done in a separate change, I'm happy to split.
Simon Hausmann
Comment 3 2010-02-10 14:35:57 PST
Comment on attachment 48133 [details] Patch v1 Nice! Thanks :)
Simon Hausmann
Comment 4 2010-02-10 14:36:15 PST
(In reply to comment #2) > (From update of attachment 48133 [details]) > > diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp > > index aeb7a22..bc00f1b 100644 > > --- a/WebKit/qt/Api/qwebframe.cpp > > +++ b/WebKit/qt/Api/qwebframe.cpp > > @@ -214,12 +214,23 @@ QString QWEBKIT_EXPORT qt_drt_counterValueForElementById(QWebFrame* qFrame, cons > > { > > Frame* frame = QWebFramePrivate::core(qFrame); > > if (Document* document = frame->document()) { > > - Element* element = document->getElementById(id); > > - return WebCore::counterValueForElement(element); > > + if (Element* element = document->getElementById(id)) > > + return WebCore::counterValueForElement(element); > > This change is not related to this change, but I think it's small enough to fix > with the main change. This change avoids crash when a nonexistent element ID is > specified. If a reviewer considers this should be done in a separate change, > I'm happy to split. No worries and good catch :)
Kenneth Rohde Christiansen
Comment 5 2010-02-10 14:48:45 PST
Didn't diego do the exact same patch today?
Antonio Gomes
Comment 6 2010-02-10 19:01:50 PST
(In reply to comment #5) > Didn't diego do the exact same patch today? yes, see bug 34777, which has landed. *** This bug has been marked as a duplicate of bug 34777 ***
Shinichiro Hamaji
Comment 7 2010-04-25 09:15:40 PDT
Though the main change was done by Diego, I'll land the r+ed patch only with the crash fix.
Shinichiro Hamaji
Comment 8 2010-04-25 09:17:14 PDT
Note You need to log in before you can comment on or make changes to this bug.