Issue #149 - avoid crash on null attr value

This commit is contained in:
Geoff McLane 2015-02-03 13:38:20 +01:00
parent d38c5c5d78
commit 698396eaa0

View file

@ -965,13 +965,15 @@ static void FreeAnchor(TidyDocImpl* doc, Anchor *a)
static uint anchorNameHash(ctmbstr s) static uint anchorNameHash(ctmbstr s)
{ {
uint hashval; uint hashval = 0;
/* Issue #149 - an inferred name can be null. avoid crash */
for (hashval = 0; *s != '\0'; s++) { if (s)
{
for ( ; *s != '\0'; s++) {
tmbchar c = TY_(ToLower)( *s ); tmbchar c = TY_(ToLower)( *s );
hashval = c + 31*hashval; hashval = c + 31*hashval;
} }
}
return hashval % ANCHOR_HASH_SIZE; return hashval % ANCHOR_HASH_SIZE;
} }