]> granicus.if.org Git - php/commitdiff
Fixed bug #21338 (crash inside html_entity_decode() when "" is passed).
authorIlia Alshanetsky <iliaa@php.net>
Thu, 2 Jan 2003 19:49:30 +0000 (19:49 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 2 Jan 2003 19:49:30 +0000 (19:49 +0000)
Added test case for the bug.

ext/standard/html.c
ext/standard/tests/strings/bug21338.phpt [new file with mode: 0644]

index 5385d5609ccd3bded909b40eecd4115fec44a626..4e7d51be5985b593cc7f634bacf3df6b0de8e7c2 100644 (file)
@@ -674,6 +674,9 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new
        
        ret = estrdup(old);
        retlen = oldlen;
+       if (!retlen) {
+               goto empty_source;
+       }
        
        if (all) {
                /* look for a match in the maps for this charset */
@@ -722,7 +725,7 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new
                efree(ret);
                ret = replaced;
        }
-       
+empty_source:  
        *newlen = retlen;
        return ret;
 }
diff --git a/ext/standard/tests/strings/bug21338.phpt b/ext/standard/tests/strings/bug21338.phpt
new file mode 100644 (file)
index 0000000..c845765
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+Bug #20934 (html_entity_decode() crash when "" is passed)
+--FILE--
+<?php
+       var_dump(html_entity_decode(NULL));
+       var_dump(html_entity_decode(""));
+?>
+--EXPECT--
+string(0) ""
+string(0) ""