I reproduced this bug, found the problem, and fixed it.  Patch attached.

The problem is in the usage of get_attribute, which is a variable
argument function.  The function checks for a NULL (char *) argument
to terminate processing.  Callers used 0 to represent the end of
the list, which fails on architectures where int is not the same
length as (char *).  Callers should use NULL when they mean NULL.

C++ blurs the difference between 0 and NULL much more than C.
In a variable argument function call, there is still a difference.

libefence and gdb are nice, but eventually I chased this down
with good ol' printf's.

        - Larry
diff -ur html2text-1.3.2a/format.C html2text-1.3.2a-fixed/format.C
--- html2text-1.3.2a/format.C   2003-11-23 03:05:29.000000000 -0800
+++ html2text-1.3.2a-fixed/format.C     2005-04-27 11:47:06.023515000 -0700
@@ -560,7 +560,7 @@
     "LEFT",   Area::LEFT,
     "CENTER", Area::CENTER,
     "RIGHT",  Area::RIGHT,
-    0
+    NULL
   );
 
   static char cell_attributes[7];
@@ -682,7 +682,7 @@
     "LEFT",   Area::LEFT,
     "CENTER", Area::CENTER,
     "RIGHT",  Area::RIGHT,
-    0
+    NULL
   );
 
   static BlockFormat bf("P");
@@ -752,7 +752,7 @@
       "LEFT",   Area::LEFT,
       "MIDDLE", Area::CENTER,
       "RIGHT",  Area::RIGHT,
-      0
+      NULL
     );
     Area *a = ::format(content.get(), w, halign);
     if (a) return a;
@@ -802,7 +802,7 @@
     "LEFT",   Area::LEFT,
     "CENTER", Area::CENTER,
     "RIGHT",  Area::RIGHT,
-    0
+    NULL
   ));
 }
 
@@ -1632,7 +1632,7 @@
     "A",         UPPER_ALPHA,
     "i",         LOWER_ROMAN,
     "I",         UPPER_ROMAN,
-    0
+    NULL
   );
 }
 
diff -ur html2text-1.3.2a/table.C html2text-1.3.2a-fixed/table.C
--- html2text-1.3.2a/table.C    2002-07-22 04:32:50.000000000 -0700
+++ html2text-1.3.2a-fixed/table.C      2005-04-27 11:48:03.336833000 -0700
@@ -122,14 +122,14 @@
       "LEFT",   Area::LEFT,
       "CENTER", Area::CENTER,
       "RIGHT",  Area::RIGHT,
-      0
+      NULL
     );
     int row_valign = get_attribute(
       row.attributes.get(), "VALIGN", Area::MIDDLE,
       "TOP",    Area::LEFT,
       "MIDDLE", Area::MIDDLE,
       "BOTTOM", Area::BOTTOM,
-      0
+      NULL
     );
 
     const list<auto_ptr<TableCell> >           &cl(*row.cells);
@@ -158,14 +158,14 @@
         "LEFT",   Area::LEFT,
         "CENTER", Area::CENTER,
         "RIGHT",  Area::RIGHT,
-        0
+        NULL
       );
       p->valign    = get_attribute(
         cell.attributes.get(), "VALIGN", row_valign,
         "TOP",    Area::TOP,
         "MIDDLE", Area::MIDDLE,
         "BOTTOM", Area::BOTTOM,
-        0
+        NULL
       );
       {
        auto_ptr<Area> tmp(cell.format(
@@ -386,7 +386,7 @@
     "LEFT",   Area::LEFT,
     "CENTER", Area::CENTER,
     "RIGHT",  Area::RIGHT,
-    0
+    NULL
   );
 
   // <TABLE>          => default => no border

Attachment: signature.asc
Description: Digital signature

Reply via email to