[webkit-dev] String::impl() returns NULL causes crash

Mo, Zhenyao zhenyao at gmail.com
Wed Apr 13 18:15:04 PDT 2011


You are right.  I figured out the issue.

It would be nice to ASSERT in the hash() functions (instead of in the
header) so people who encounter the NULL input will understand
immediately something else is wrong.

On Wed, Apr 13, 2011 at 6:04 PM, Gavin Barraclough
<barraclough at apple.com> wrote:
> On Apr 13, 2011, at 5:32 PM, Mo, Zhenyao wrote:
>
> What value should we return for hash(NULL)?
>
> From the top of the file:
>     // The hash() functions on StringHash and CaseFoldingHash do not support
>     // null strings. get(), contains(), and add() on HashMap<String,...,
> StringHash>
>     // cause a null-pointer dereference when passed null strings.
> In the hash traits for String, we use String() as the empty value for hash
> tables keyed on a string.  Our hash tables will not work correctly if the
> hash trait's empty value is used as a key in the table, so allowing a null
> string to be hashed & used as a key would only result in later errors.  We
> should probably ASSERT in the hash methods that the Strings/StringImpls
> passed to the hash() methods in StringHash are not null.
> To fix your problem you will need to find what is using a null string as a
> key in a hashtable, and stop it – making hash() return a value for the null
> string will not fix this bug.
> cheers,
> G.
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
>
>


More information about the webkit-dev mailing list