[Webkit-unassigned] [Bug 96272] NPN_InitializeVariantWithStringCopy is wrong for platforms that return NULL from malloc(0)

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jan 24 11:27:36 PST 2013


https://bugs.webkit.org/show_bug.cgi?id=96272





--- Comment #21 from Alexey Proskuryakov <ap at webkit.org>  2013-01-24 11:29:30 PST ---
(From update of attachment 184523)
View in context: https://bugs.webkit.org/attachment.cgi?id=184523&action=review

This is going for way too long already, but I have additional comments, sorry about that.

> Source/WebCore/ChangeLog:8
> +        See bug 96272 comments for further information.

This is not helpful - the bug number is the same as above, so of course one would go there for additional information.

> Source/WebCore/bridge/npruntime.cpp:91
> +        variant->value.stringValue.UTF8Characters = (NPUTF8 *)malloc(sizeof(NPUTF8) * value->UTF8Length);

This is a pre-existing error, but WebKit style is to put star next to C++ class name (so it would be "(NPUTF8*)). It's also WebKit style to use static_cast over C-style casts, although I personally don't see that as beneficial in cases like this.

> Source/WebCore/bridge/npruntime.cpp:93
> +        if (!variant->value.stringValue.UTF8Characters)
> +            CRASH();

Can't we just change this check to the one below?

if (value->UTF8Length && !variant->value.stringValue.UTF8Characters)
    CRASH();

That would be a much smaller change, and more readable code, I think.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list