[cairo] cairo crash in _cairo_hash_string
spitzak at d2.com
Wed Aug 17 12:30:01 PDT 2005
Carl Worth wrote:
> On Wed, 17 Aug 2005 11:46:33 -0700, Bill Spitzak wrote:
>>You may want null and zero-length strings to hash differently.
> I can't imagine any reason why, (at least in the context of font
> filenames as we're talking about here).
Probably not, but it bit me in some code I was wrote. Actually I had
more trouble in that my hash function for a zero-length string was the
same as not calling it at all. This caused a very hard to locate bug,
because there were two string pointers contributing to the hash, and if
one of them was null, swapping the two values produced the same hash.
For font filenames it is likely that null and zero-length strings are
illegal or useless, so this does not matter, like you said.
> But, as it turns out, the NULL-filename case that was triggering this
> bug also never uses the hash value anyway. It's fixed in CVS to not
> even try computing a hash value in this case.
This sounds like the best fix. If null is not allowed it is best to have
that hash crash, rathern than hiding a bug.
More information about the cairo