Bug 49342 - [Qt] QWebScriptWorld::world() may crash
Summary: [Qt] QWebScriptWorld::world() may crash
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-10 13:49 PST by Yi Shen
Modified: 2010-11-11 06:51 PST (History)
2 users (show)

See Also:


Attachments
first try (969 bytes, patch)
2010-11-10 13:52 PST, Yi Shen
no flags Details | Formatted Diff | Diff
second try (990 bytes, patch)
2010-11-11 03:07 PST, Yi Shen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yi Shen 2010-11-10 13:49:11 PST
It might be trivial but we'd better check the value of the private data in the QWebScriptWorld::world() to prevent the possible crash -- 'd' may have an empty data if USE(JSC) is undefined for some platform.

QWebScriptWorld::QWebScriptWorld()
{
#if USE(JSC) // d can have an empty data if this macro fails
    d = new QWebScriptWorldPrivate(ScriptController::createWorld());    
#endif
}
Comment 1 Yi Shen 2010-11-10 13:52:18 PST
Created attachment 73536 [details]
first try
Comment 2 Kenneth Rohde Christiansen 2010-11-11 01:34:23 PST
Comment on attachment 73536 [details]
first try

View in context: https://bugs.webkit.org/attachment.cgi?id=73536&action=review

> WebKit/qt/Api/qwebscriptworld.cpp:53
> +    return d.data() ? d->world.get() : NULL;

huh? how does world depend on data() ? Also we do not use NULL in C++ code.
Comment 3 Yi Shen 2010-11-11 03:07:43 PST
Created attachment 73593 [details]
second try
Comment 4 Yi Shen 2010-11-11 03:10:32 PST
(In reply to comment #2)
> (From update of attachment 73536 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=73536&action=review
> 
> > WebKit/qt/Api/qwebscriptworld.cpp:53
> > +    return d.data() ? d->world.get() : NULL;
> 
> huh? how does world depend on data() ? Also we do not use NULL in C++ code.

Thanks, you are right. I updated my patch, which returns 0 when the internal pointer to the shared data object is not null.
Comment 5 Andreas Kling 2010-11-11 03:11:25 PST
Comment on attachment 73593 [details]
second try

This is a purely artificial problem since we always build with USE(JSC) and the V8 port will most likely require large changes to QWebScriptWorld anyway.
That said, I don't see any harm in adding this check. r=me
Comment 6 WebKit Commit Bot 2010-11-11 06:51:01 PST
Comment on attachment 73593 [details]
second try

Clearing flags on attachment: 73593

Committed r71818: <http://trac.webkit.org/changeset/71818>
Comment 7 WebKit Commit Bot 2010-11-11 06:51:07 PST
All reviewed patches have been landed.  Closing bug.