Bug and (bad ?) fix

Hi, the file at http://www.openbsd.org/faq/faq8.html
makes tidy core dump (the HTML is not exactly nice...)

The problem occurs in the parser (parser.c), sometimes
node->tag is NULL and there are no checks on this case,
so for example accessing node->tag->model crashs the
program.

My patch add some lacking checks to the program, but my
guess is that the good fix should be to ensure that
node->tag has always a sensible value...

Here's the patch :

--- parser.c.orig       Tue Nov 30 11:44:51 1999
+++ parser.c    Wed Dec 22 03:34:47 1999
@@ -356,6 +356,9 @@
 
 void ParseTag(Lexer *lexer, Node *node, uint mode)
 {
+    if (!node->tag)
+        return;
+
     if (node->tag->model & CM_EMPTY)
     {
         lexer->waswhite = no;
@@ -1435,7 +1438,7 @@
             continue;
         }
 
-        if (node->tag != tag_li)
+        if ((node->tag != tag_li) && node->tag)
         {
             UngetToken(lexer);
 

-- 
Evangelists do it with Him watching.

Received on Tuesday, 21 December 1999 22:12:13 UTC