Subject: | [PATCH] fixing coredumps in 1.08 |
It looks like Tidy.xs does not initializes libtidy's buffers correctly,
which sometimes leads to segfaults. Please note that the presense of
the segfault might or might not depend on the particular OS malloc(3)
implementation, so "I cannot reproduce it, case closed" is not welcome.
The code is still buggy.
A simple case to reproduce this problem was produced by lbr@freebsd.org:
$ perl -e 'use Test::HTML::Tidy tests=>1; html_tidy_ok(qq{<?xml
version="1.0" encoding="utf-8"?>\n<\!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML1.1//EN"\n"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\n<html
xmlns="http://www.w3.org/1999/
xhtml"\nxml:lang="en">\n<head><title>test</title></head><body>output</
Show quoted text
body></html>}, "");'
Please see attached patch for a fix.
Cheers,
\Anton.
Subject: | tidy.patch |
--- Tidy.xs.orig 2007-09-24 11:36:19.000000000 +0200
+++ Tidy.xs 2007-09-24 11:37:42.000000000 +0200
@@ -55,6 +55,7 @@ _tidy_messages(input, configfile, tidy_o
const char* newline;
int rc = 0;
PPCODE:
+ tidyBufInit(&errbuf);
rc = ( tidyOptSetValue( tdoc, TidyCharEncoding, "utf8" ) ? rc : -1 );
if ( (rc >= 0 ) && configfile && *configfile ) {
@@ -117,6 +118,8 @@ _tidy_clean(input, configfile, tidy_opti
const char* newline;
int rc = 0;
PPCODE:
+ tidyBufInit(&output);
+ tidyBufInit(&errbuf);
/* Set our default first. */
/* Don't word-wrap */
rc = ( tidyOptSetInt( tdoc, TidyWrapLen, 0 ) ? rc : -1 );