]> granicus.if.org Git - php/commitdiff
Fixed bug #72463 mail fails with invalid argument
authorAnatol Belski <ab@php.net>
Wed, 22 Jun 2016 17:05:31 +0000 (19:05 +0200)
committerAnatol Belski <ab@php.net>
Wed, 22 Jun 2016 17:06:33 +0000 (19:06 +0200)
ext/pcre/php_pcre.c
ext/pcre/tests/bug72463.phpt [new file with mode: 0644]

index ed0f3b3ac491b1bebbda9423d378e4c671b51297..356b5dc95abf3f996332e6cc06247e6d9a10d2b8 100644 (file)
@@ -1331,7 +1331,7 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
                                        break;
                                }
                                new_len = result_len + subject_len - start_offset;
-                               if (new_len > alloc_len) {
+                               if (new_len >= alloc_len) {
                                        alloc_len = new_len; /* now we know exactly how long it is */
                                        if (NULL != result) {
                                                result = zend_string_realloc(result, alloc_len, 0);
diff --git a/ext/pcre/tests/bug72463.phpt b/ext/pcre/tests/bug72463.phpt
new file mode 100644 (file)
index 0000000..c164616
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #72463 mail fails with invalid argument
+--FILE--
+<?php
+
+@mail("some.address.it.wont.ever.reach@lookup.and.try.to.find.this.host.name","subject","a", "");
+@mail("some.address.it.wont.ever.reach@lookup.and.try.to.find.this.host.name","subject","a", NULL);
+
+?>
+===DONE===
+--EXPECTF--
+===DONE===