summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2003-01-02 19:49:30 +0000
committerIlia Alshanetsky <iliaa@php.net>2003-01-02 19:49:30 +0000
commit0ff59a1353fcf232a73c8946746fa7d93e5e1096 (patch)
tree9b3b7d34f162fb86ca1889c1e4cc0a3a847a0729 /ext
parentb46352043c69880e97d3487458a63467e355cc3a (diff)
downloadphp-git-0ff59a1353fcf232a73c8946746fa7d93e5e1096.tar.gz
Fixed bug #21338 (crash inside html_entity_decode() when "" is passed).
Added test case for the bug.
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/html.c5
-rw-r--r--ext/standard/tests/strings/bug21338.phpt10
2 files changed, 14 insertions, 1 deletions
diff --git a/ext/standard/html.c b/ext/standard/html.c
index 5385d5609c..4e7d51be59 100644
--- a/ext/standard/html.c
+++ b/ext/standard/html.c
@@ -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
index 0000000000..c84576563e
--- /dev/null
+++ b/ext/standard/tests/strings/bug21338.phpt
@@ -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) ""