]> granicus.if.org Git - php/commitdiff
fix a couple of leaks, add new test
authorAntony Dovgal <tony2001@php.net>
Wed, 30 Aug 2006 22:32:35 +0000 (22:32 +0000)
committerAntony Dovgal <tony2001@php.net>
Wed, 30 Aug 2006 22:32:35 +0000 (22:32 +0000)
ext/tidy/tests/022.phpt [new file with mode: 0644]
ext/tidy/tidy.c

diff --git a/ext/tidy/tests/022.phpt b/ext/tidy/tests/022.phpt
new file mode 100644 (file)
index 0000000..9d2c693
--- /dev/null
@@ -0,0 +1,38 @@
+--TEST--
+tidy_repair_*() and invalid parameters
+--SKIPIF--
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
+--FILE--
+<?php
+
+$l = 1;
+$s = "";
+$a = array();
+
+tidy_repair_string($s, $l, $l, $l);
+tidy_repair_string($s, $s, $s, $s);
+tidy_repair_string($l, $l, $l ,$l);
+tidy_repair_string($a, $a, $a, $a);
+
+tidy_repair_file($s, $l, $l, $l);
+tidy_repair_file($s, $s, $s, $s);
+tidy_repair_file($l, $l, $l ,$l);
+tidy_repair_file($a, $a, $a, $a);
+
+echo "Done\n";
+?>
+--EXPECTF--    
+Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not load configuration file '' in %s on line %d
+
+Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d
+
+Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d
+
+Warning: tidy_repair_string() expects parameter 1 to be string, array given in %s on line %d
+
+Warning: tidy_repair_file() expects parameter 1 to be string, array given in %s on line %d
+Done
index 7e14c64e768577f0fd1e402434140670250dc2d6..1addb08b8092801781ae8458cd251ed4a669aab2 100644 (file)
@@ -89,7 +89,7 @@
         if(Z_TYPE_P(_val) == IS_ARRAY) { \
             _php_tidy_apply_config_array(_doc, HASH_OF(_val) TSRMLS_CC); \
         } else { \
-            convert_to_string_ex(&_val); \
+            convert_to_string(_val); \
             TIDY_OPEN_BASEDIR_CHECK(Z_STRVAL_P(_val)); \
             switch (tidyLoadConfig(_doc, Z_STRVAL_P(_val))) { \
               case -1: \
@@ -1398,7 +1398,7 @@ static PHP_FUNCTION(tidy_getopt)
        optval = php_tidy_get_opt_val(obj->ptdoc, opt, &optt TSRMLS_CC);
        switch (optt) {
                case TidyString:
-                       RETURN_ASCII_STRING((char *)optval, 0);
+                       RETURN_ASCII_STRING((char *)optval, ZSTR_AUTOFREE);
                        break;
 
                case TidyInteger: