[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#682480: unblock: php5/5.4.5-1



Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Please unblock package php5

Hi,

would you please consider unblocking php5 5.4.5?  I am attaching
stripped down upstream patch, which I manually edited and removed:

- whitespace changes
- s/occured/occurred/ and other	typo fixes
- mysqlnd charset table update
- changes and additions in automated PHP tests
- changes in $Id: hashes
- changes in ZEND declaration removing semicolon at the end:
  -ZEND_DECLARE_MODULE_GLOBALS(browscap);                                                                                                                                                          
  +ZEND_DECLARE_MODULE_GLOBALS(browscap)
- embeded libzip update
  + I have tried to use system library, but it segfaulted
- updates to win32 code
- re2c generated parsers/lexers

Once you do that, the patch is not that horrible:

$ diffstat php5-5.4.4-5.4.5.patch
[...]
 73 files changed, 691 insertions(+), 365 deletions(-)

The main reason for the freeze-exception is to stay as close as
possible with upstream.  You know we had 16 security updates for lenny
and already 13 for squeeze, so anything which could help me with the
burden would be much appreciated.  Well and the CVE-2012-2688 will
need another round of update :( now.

Anyway, I'll be importing and uploading php5 5.4.5-1 to experimental,
so we don't have to juggle with t-p-u in case my humble proposal is
not accepted. 

unblock php5/5.4.5-1

Upstream CHANGES for 5.4.5:

PHP                                                                        NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
19 Jul 2012, PHP 5.4.5

- Core:
  . Fixed bug #62443 (Crypt SHA256/512 Segfaults With Malformed 
    Salt). (Anthony Ferrara)
  . Fixed bug #62432 (ReflectionMethod random corrupt memory on high
    concurrent). (Johannes)
  . Fixed bug #62373 (serialize() generates wrong reference to the object).
    (Moriyoshi)
  . Fixed bug #62357 (compile failure: (S) Arguments missing for built-in
    function __memcmp). (Laruence)
  . Fixed bug #61998 (Using traits with method aliases appears to result in
    crash during execution). (Dmitry)
  . Fixed bug #51094 (parse_ini_file() with INI_SCANNER_RAW cuts a value that
    includes a semi-colon). (Pierrick)
  . Fixed potential overflow in _php_stream_scandir (CVE-2012-2688). 
    (Jason Powell, Stas)

- EXIF:
  . Fixed information leak in ext exif (discovered by Martin Noga, 
    Matthew "j00ru" Jurczyk, Gynvael Coldwind)

- FPM:
  . Fixed bug #62205 (php-fpm segfaults (null passed to strstr)). (fat)
  . Fixed bug #62160 (Add process.priority to set nice(2) priorities). (fat)
  . Fixed bug #62153 (when using unix sockets, multiples FPM instances
  . Fixed bug #62033 (php-fpm exits with status 0 on some failures to start).
    (fat)
  . Fixed bug #61839 (Unable to cross-compile PHP with --enable-fpm). (fat)
  . Fixed bug #61835 (php-fpm is not allowed to run as root). (fat)
  . Fixed bug #61295 (php-fpm should not fail with commented 'user'
  . Fixed bug #61218 (FPM drops connection while receiving some binary values
    in FastCGI requests). (fat)
  . Fixed bug #61045 (fpm don't send error log to fastcgi clients). (fat)
    for non-root start). (fat)
  . Fixed bug #61026 (FPM pools can listen on the same address). (fat)
    can be launched without errors). (fat)

- Iconv:
  . Fix bug #55042 (Erealloc in iconv.c unsafe). (Stas)

- Intl:
  . Fixed bug #62083 (grapheme_extract() memory leaks). (Gustavo)
  . ResourceBundle constructor now accepts NULL for the first two arguments.
    (Gustavo)
  . Fixed bug #62081 (IntlDateFormatter constructor leaks memory when called
    twice). (Gustavo)
  . Fixed bug #62070 (Collator::getSortKey() returns garbage). (Gustavo)
  . Fixed bug #62017 (datefmt_create with incorrectly encoded timezone leaks
    pattern). (Gustavo)
  . Fixed bug #60785 (memory leak in IntlDateFormatter constructor). (Gustavo)

- JSON:
  . Fixed bug #61359 (json_encode() calls too many reallocs). (Stas)

- libxml:
  . Fixed bug #62266 (Custom extension segfaults during xmlParseFile with FPM
    SAPI). (Gustavo)

- Phar:
  . Fixed bug #62227 (Invalid phar stream path causes crash). (Felipe)

- Readline:
  . Fixed bug #62186 (readline fails to compile - void function should not
    return a value). (Johannes)

- Reflection:
  . Fixed bug #62384 (Attempting to invoke a Closure more than once causes 
    segfault). (Felipe)
  . Fixed bug #62202 (ReflectionParameter::getDefaultValue() memory leaks 
    with constant). (Laruence)

- Sockets:
  . Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe)
    
- SPL:
  . Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to
    dot files). (Laruence)
  . Fixed bug #62262 (RecursiveArrayIterator does not implement Countable).
    (Nikita Popov)

- XML Writer:
  . Fixed bug #62064 (memory leak in the XML Writer module). 
    (jean-pierre dot lozi at lip6 dot fr)

- Zip:
  . Upgraded libzip to 0.10.1 (Anatoliy)


-- System Information:
Debian Release: 6.0.4
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable'), (300, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
diff -urNapw php-5.4.4/ext/exif/exif.c php-5.4.5/ext/exif/exif.c
--- php-5.4.4/ext/exif/exif.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/exif/exif.c	2012-07-18 08:19:16.000000000 +0200
@@ -3254,7 +3254,7 @@ static void exif_process_APP12(image_inf
 	if ((l1 = php_strnlen(buffer+2, length-2)) > 0) {
 		exif_iif_add_tag(ImageInfo, SECTION_APP12, "Company", TAG_NONE, TAG_FMT_STRING, l1, buffer+2 TSRMLS_CC);
 		if (length > 2+l1+1) {
-			l2 = php_strnlen(buffer+2+l1+1, length-2-l1+1);
+			l2 = php_strnlen(buffer+2+l1+1, length-2-l1-1);
 			exif_iif_add_tag(ImageInfo, SECTION_APP12, "Info", TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1 TSRMLS_CC);
 		}
 	}
@@ -3404,6 +3404,10 @@ static int exif_scan_JPEG_header(image_i
 			case M_SOF13:
 			case M_SOF14:
 			case M_SOF15:
+				if ((itemlen - 2) < 6) {
+					return FALSE;
+				}
+		
 				exif_process_SOFn(Data, marker, &sof_info);
 				ImageInfo->Width  = sof_info.width;
 				ImageInfo->Height = sof_info.height;
diff -urNapw php-5.4.4/ext/fileinfo/libmagic/softmagic.c php-5.4.5/ext/fileinfo/libmagic/softmagic.c
--- php-5.4.4/ext/fileinfo/libmagic/softmagic.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/fileinfo/libmagic/softmagic.c	2012-07-18 08:19:16.000000000 +0200
@@ -1654,29 +1654,6 @@ convert_libmagic_pattern(zval *pattern,
 		
 		for (i=0; i<Z_STRLEN_P(pattern); i++, j++) {
 			switch (Z_STRVAL_P(pattern)[i]) {
-				case '?':
-					t[j] = '.';
-					break;
-				case '*':
-					t[j++] = '.';
-					t[j] = '*';
-					break;
-				case '.':
-					t[j++] = '\\';
-					t[j] = '.';
-					break;
-				case '\\':
-					t[j++] = '\\';
-					t[j] = '\\';
-					break;
-				case '(':
-					t[j++] = '\\';
-					t[j] = '(';
-					break;
-				case ')':
-					t[j++] = '\\';
-					t[j] = ')';
-					break;
 				case '~':
 					t[j++] = '\\';
 					t[j] = '~';
@@ -1873,7 +1850,7 @@ magiccheck(struct magic_set *ms, struct
 		
 		convert_libmagic_pattern(pattern, options);
 		
-		l = 0;
+		l = v = 0;
 #if (PHP_MAJOR_VERSION < 6)
 		if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
 #else
diff -urNapw php-5.4.4/ext/fileinfo/libmagic.patch php-5.4.5/ext/fileinfo/libmagic.patch
--- php-5.4.4/ext/fileinfo/libmagic.patch	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/fileinfo/libmagic.patch	2012-07-18 08:19:16.000000000 +0200
@@ -2876,29 +2874,6 @@ diff -u libmagic.orig/softmagic.c libmag
 +		
 +		for (i=0; i<Z_STRLEN_P(pattern); i++, j++) {
 +			switch (Z_STRVAL_P(pattern)[i]) {
-+				case '?':
-+					t[j] = '.';
-+					break;
-+				case '*':
-+					t[j++] = '.';
-+					t[j] = '*';
-+					break;
-+				case '.':
-+					t[j++] = '\\';
-+					t[j] = '.';
-+					break;
-+				case '\\':
-+					t[j++] = '\\';
-+					t[j] = '\\';
-+					break;
-+				case '(':
-+					t[j++] = '\\';
-+					t[j] = '(';
-+					break;
-+				case ')':
-+					t[j++] = '\\';
-+					t[j] = ')';
-+					break;
 +				case '~':
 +					t[j++] = '\\';
 +					t[j] = '~';
@@ -2937,23 +2912,7 @@ diff -u libmagic.orig/softmagic.c libmag
 -		if (ms->search.s == NULL)
 -			return 0;
 -
-+		zval *pattern;
-+		int options = 0;
-+		pcre_cache_entry *pce;
-+		TSRMLS_FETCH();
-+		
-+		MAKE_STD_ZVAL(pattern);
-+		ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0);
-+	
-+		options |= PCRE_MULTILINE;
-+		
-+		if (m->str_flags & STRING_IGNORE_CASE) {
-+			options |= PCRE_CASELESS;
-+		}
-+		
-+		convert_libmagic_pattern(pattern, options);
-+		
- 		l = 0;
+-		l = 0;
 -		rc = regcomp(&rx, m->value.s,
 -		    REG_EXTENDED|REG_NEWLINE|
 -		    ((m->str_flags & STRING_IGNORE_CASE) ? REG_ICASE : 0));
@@ -2970,6 +2929,23 @@ diff -u libmagic.orig/softmagic.c libmag
 -			size_t l = ms->search.s_len - 1;
 -			char c = ms->search.s[l];
 -			((char *)(intptr_t)ms->search.s)[l] = '\0';
++		zval *pattern;
++		int options = 0;
++		pcre_cache_entry *pce;
++		TSRMLS_FETCH();
++		
++		MAKE_STD_ZVAL(pattern);
++		ZVAL_STRINGL(pattern, (char *)m->value.s, m->vallen, 0);
++	
++		options |= PCRE_MULTILINE;
++		
++		if (m->str_flags & STRING_IGNORE_CASE) {
++			options |= PCRE_CASELESS;
++		}
++		
++		convert_libmagic_pattern(pattern, options);
++		
++		l = v = 0;
 +#if (PHP_MAJOR_VERSION < 6)
 +		if ((pce = pcre_get_compiled_regex_cache(Z_STRVAL_P(pattern), Z_STRLEN_P(pattern) TSRMLS_CC)) == NULL) {
  #else
diff -urNapw php-5.4.4/ext/iconv/iconv.c php-5.4.5/ext/iconv/iconv.c
--- php-5.4.4/ext/iconv/iconv.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/iconv/iconv.c	2012-07-18 08:19:16.000000000 +0200
@@ -513,7 +513,11 @@ PHP_ICONV_API php_iconv_err_t php_iconv_
 	}
 
 	if (out_left < 8) {
-		out_buffer = (char *) erealloc(out_buffer, out_size + 8);
+		size_t pos = out_p - out_buffer;
+		out_buffer = (char *) safe_erealloc(out_buffer, out_size, 1, 8);
+		out_p = out_buffer+pos;
+		out_size += 7;
+		out_left += 7;
 	}
 
 	/* flush the shift-out sequences */ 
diff -urNapw php-5.4.4/ext/intl/dateformat/dateformat.c php-5.4.5/ext/intl/dateformat/dateformat.c
--- php-5.4.4/ext/intl/dateformat/dateformat.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/dateformat/dateformat.c	2012-07-18 08:19:16.000000000 +0200
@@ -99,17 +99,46 @@ static void datefmt_ctor(INTERNAL_FUNCTI
     }
 
 	INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
+	
+	if (calendar != UCAL_TRADITIONAL && calendar != UCAL_GREGORIAN) {
+		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: "
+				"invalid value for calendar type; it must be one of "
+				"IntlDateFormatter::TRADITIONAL (locale's default calendar) "
+				"or IntlDateFormatter::GREGORIAN", 0 TSRMLS_CC);
+		goto error;
+	}
+	
 	DATE_FORMAT_METHOD_FETCH_OBJECT;
+	
+	if (DATE_FORMAT_OBJECT(dfo) != NULL) {
+		intl_errors_set(INTL_DATA_ERROR_P(dfo), U_ILLEGAL_ARGUMENT_ERROR,
+				"datefmt_create: cannot call constructor twice", 0 TSRMLS_CC);
+		return;
+	}
+	
 	/* Convert pattern (if specified) to UTF-16. */
 	if( pattern_str && pattern_str_len>0 ){
-		intl_convert_utf8_to_utf16(&svalue, &slength, pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo));
-		INTL_CTOR_CHECK_STATUS(dfo, "datefmt_create: error converting pattern to UTF-16");
+		intl_convert_utf8_to_utf16(&svalue, &slength,
+				pattern_str, pattern_str_len, &INTL_DATA_ERROR_CODE(dfo));
+		if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
+			/* object construction -> only set global error */
+			intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
+					"error converting pattern to UTF-16", 0 TSRMLS_CC);
+			goto error;
+		}
 	}
 
+	/* resources allocated from now on */
+
 	/* Convert pattern (if specified) to UTF-16. */
 	if( timezone_str && timezone_str_len >0 ){
-		intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len, timezone_str, timezone_str_len, &INTL_DATA_ERROR_CODE(dfo));
-		INTL_CTOR_CHECK_STATUS(dfo, "datefmt_create: error converting timezone_str to UTF-16" );
+		intl_convert_utf8_to_utf16(&timezone_utf16, &timezone_utf16_len,
+				timezone_str, timezone_str_len, &INTL_DATA_ERROR_CODE(dfo));
+		if (U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
+			intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create: "
+					"error converting timezone_str to UTF-16", 0 TSRMLS_CC);
+			goto error;
+		}
 	}
 
 	if(locale_len == 0) {
@@ -122,25 +151,25 @@ static void datefmt_ctor(INTERNAL_FUNCTI
 		DATE_FORMAT_OBJECT(dfo) = udat_open(time_type, date_type, locale, timezone_utf16, timezone_utf16_len, svalue, slength, &INTL_DATA_ERROR_CODE(dfo));
 	}
 
-    /* Set the calendar if passed */
-    if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo)) && calendar) {
-		ucal_obj = ucal_open( timezone_utf16, timezone_utf16_len, locale, calendar, &INTL_DATA_ERROR_CODE(dfo) );
+    if (!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
+		if (calendar != UCAL_TRADITIONAL) {
+			ucal_obj = ucal_open(timezone_utf16, timezone_utf16_len, locale,
+					calendar, &INTL_DATA_ERROR_CODE(dfo));
 		if(!U_FAILURE(INTL_DATA_ERROR_CODE(dfo))) {
 			udat_setCalendar( DATE_FORMAT_OBJECT(dfo), ucal_obj );
+				ucal_close(ucal_obj);
+			} else {
+				intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo), "datefmt_create"
+						": error opening calendar", 0 TSRMLS_CC);
+				goto error;
 		}
     }
-
-	if(svalue)
-	{
-		efree(svalue);
-	}
-	if(timezone_utf16)
-	{
-		efree(timezone_utf16);
+    } else {
+		intl_error_set(NULL, INTL_DATA_ERROR_CODE(dfo),	"datefmt_create: date "
+				"formatter creation failed", 0 TSRMLS_CC);
+		goto error;
 	}
 
-	INTL_CTOR_CHECK_STATUS(dfo, "datefmt_create: date formatter creation failed");
-
 	/* Set the class variables */
 	dfo->date_type = date_type;
 	dfo->time_type = time_type;
@@ -148,6 +177,19 @@ static void datefmt_ctor(INTERNAL_FUNCTI
 	if( timezone_str && timezone_str_len > 0){
 		dfo->timezone_id = estrndup( timezone_str, timezone_str_len);
 	}
+	
+error:
+	if (svalue) {
+		efree(svalue);
+	}
+	if (timezone_utf16) {
+		efree(timezone_utf16);
+	}
+	if (U_FAILURE(intl_error_get_code(NULL TSRMLS_CC))) {
+		/* free_object handles partially constructed instances fine */
+		zval_dtor(return_value);
+		RETVAL_NULL();
+	}
 }
 /* }}} */
 
@@ -169,6 +211,8 @@ PHP_FUNCTION( datefmt_create )
  */
 PHP_METHOD( IntlDateFormatter, __construct )
 {
+	/* return_value param is being changed, therefore we will always return
+	 * NULL here */
 	return_value = getThis();
 	datefmt_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
diff -urNapw php-5.4.4/ext/intl/grapheme/grapheme_string.c php-5.4.5/ext/intl/grapheme/grapheme_string.c
--- php-5.4.4/ext/intl/grapheme/grapheme_string.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/grapheme/grapheme_string.c	2012-07-18 08:19:16.000000000 +0200
@@ -822,6 +822,7 @@ PHP_FUNCTION(grapheme_extract)
 		}
 		else {
 			/* initialize next */
+			zval_dtor(next);
             ZVAL_LONG(next, lstart);
 		}
 	}
diff -urNapw php-5.4.4/ext/intl/msgformat/msgformat_attr.c php-5.4.5/ext/intl/msgformat/msgformat_attr.c
--- php-5.4.4/ext/intl/msgformat/msgformat_attr.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/msgformat/msgformat_attr.c	2012-07-18 08:19:16.000000000 +0200
@@ -82,11 +82,13 @@ PHP_FUNCTION( msgfmt_set_pattern )
 	intl_convert_utf8_to_utf16(&spattern, &spattern_len, value, value_len, &INTL_DATA_ERROR_CODE(mfo));
 	INTL_METHOD_CHECK_STATUS(mfo, "Error converting pattern to UTF-16" );
 
+#ifdef MSG_FORMAT_QUOTE_APOS
 	if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
 		intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
 			"msgfmt_set_pattern: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
 		RETURN_FALSE;
 	}
+#endif
 
 	/* TODO: add parse error information */
 	umsg_applyPattern(MSG_FORMAT_OBJECT(mfo), spattern, spattern_len, NULL, &INTL_DATA_ERROR_CODE(mfo));
diff -urNapw php-5.4.4/ext/intl/msgformat/msgformat.c php-5.4.5/ext/intl/msgformat/msgformat.c
--- php-5.4.4/ext/intl/msgformat/msgformat.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/msgformat/msgformat.c	2012-07-18 08:19:16.000000000 +0200
@@ -64,9 +64,11 @@ static void msgfmt_ctor(INTERNAL_FUNCTIO
 		locale = INTL_G(default_locale);
 	}
 
+#ifdef MSG_FORMAT_QUOTE_APOS
 	if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
 		INTL_CTOR_CHECK_STATUS(mfo, "msgfmt_create: error converting pattern to quote-friendly format");
 	}
+#endif
 
 	if ((mfo)->mf_data.orig_format) {
 		msgformat_data_free(&mfo->mf_data TSRMLS_CC);
diff -urNapw php-5.4.4/ext/intl/msgformat/msgformat_class.h php-5.4.5/ext/intl/msgformat/msgformat_class.h
--- php-5.4.4/ext/intl/msgformat/msgformat_class.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/msgformat/msgformat_class.h	2012-07-18 08:19:16.000000000 +0200
@@ -19,9 +19,11 @@
 
 #include <php.h>
 
-#include "intl_common.h"
-#include "intl_error.h"
-#include "intl_data.h"
+#include <unicode/uconfig.h>
+
+#include "../intl_common.h"
+#include "../intl_error.h"
+#include "../intl_data.h"
 #include "msgformat_data.h"
 
 typedef struct {
@@ -38,4 +40,8 @@ extern zend_class_entry *MessageFormatte
 #define MSG_FORMAT_METHOD_FETCH_OBJECT	INTL_METHOD_FETCH_OBJECT(MessageFormatter, mfo)
 #define MSG_FORMAT_OBJECT(mfo)			(mfo)->mf_data.umsgf
 
+#if U_ICU_VERSION_MAJOR_NUM * 10 + U_ICU_VERSION_MINOR_NUM < 48
+# define MSG_FORMAT_QUOTE_APOS 1
+#endif
+
 #endif // #ifndef MSG_FORMAT_CLASS_H
diff -urNapw php-5.4.4/ext/intl/msgformat/msgformat_data.c php-5.4.5/ext/intl/msgformat/msgformat_data.c
--- php-5.4.4/ext/intl/msgformat/msgformat_data.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/msgformat/msgformat_data.c	2012-07-18 08:19:16.000000000 +0200
@@ -21,6 +21,8 @@
 #include <unicode/ustring.h>
 #include "msgformat_data.h"
 
+#include "msgformat_class.h"
+
 /* {{{ void msgformat_data_init( msgformat_data* mf_data )
  * Initialize internals of msgformat_data.
  */
@@ -69,6 +71,7 @@ msgformat_data* msgformat_data_create( T
 }
 /* }}} */
 
+#ifdef MSG_FORMAT_QUOTE_APOS
 int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec) 
 {
 	if(*spattern && *spattern_len && u_strchr(*spattern, (UChar)'\'')) {
@@ -86,6 +89,7 @@ int msgformat_fix_quotes(UChar **spatter
 	}
 	return SUCCESS;
 }
+#endif
 
 
 /*
diff -urNapw php-5.4.4/ext/intl/msgformat/msgformat_data.h php-5.4.5/ext/intl/msgformat/msgformat_data.h
--- php-5.4.4/ext/intl/msgformat/msgformat_data.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/msgformat/msgformat_data.h	2012-07-18 08:19:16.000000000 +0200
@@ -19,9 +19,9 @@
 
 #include <php.h>
 
-#include <unicode/umsg.h>
+#include "../intl_error.h"
 
-#include "intl_error.h"
+#include <unicode/umsg.h>
 
 typedef struct {
 	// error hangling
@@ -36,6 +36,9 @@ typedef struct {
 msgformat_data* msgformat_data_create( TSRMLS_D );
 void msgformat_data_init( msgformat_data* mf_data TSRMLS_DC );
 void msgformat_data_free( msgformat_data* mf_data TSRMLS_DC );
+
+#ifdef MSG_FORMAT_QUOTE_APOS
 int msgformat_fix_quotes(UChar **spattern, uint32_t *spattern_len, UErrorCode *ec);
+#endif
 
 #endif // MSG_FORMAT_DATA_H
diff -urNapw php-5.4.4/ext/intl/msgformat/msgformat_format.c php-5.4.5/ext/intl/msgformat/msgformat_format.c
--- php-5.4.4/ext/intl/msgformat/msgformat_format.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/msgformat/msgformat_format.c	2012-07-18 08:19:16.000000000 +0200
@@ -154,11 +154,13 @@ PHP_FUNCTION( msgfmt_format_message )
 		slocale = INTL_G(default_locale);
 	}
 
+#ifdef MSG_FORMAT_QUOTE_APOS
 	if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
 		intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
 			"msgfmt_format_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
 		RETURN_FALSE;
 	}
+#endif
 
 	/* Create an ICU message formatter. */
 	MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));
diff -urNapw php-5.4.4/ext/intl/msgformat/msgformat_parse.c php-5.4.5/ext/intl/msgformat/msgformat_parse.c
--- php-5.4.4/ext/intl/msgformat/msgformat_parse.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/msgformat/msgformat_parse.c	2012-07-18 08:19:16.000000000 +0200
@@ -129,11 +129,13 @@ PHP_FUNCTION( msgfmt_parse_message )
 		slocale = INTL_G(default_locale);
 	}
 
+#ifdef MSG_FORMAT_QUOTE_APOS
 	if(msgformat_fix_quotes(&spattern, &spattern_len, &INTL_DATA_ERROR_CODE(mfo)) != SUCCESS) {
 		intl_error_set( NULL, U_INVALID_FORMAT_ERROR,
 			"msgfmt_parse_message: error converting pattern to quote-friendly format", 0 TSRMLS_CC );
 		RETURN_FALSE;
 	}
+#endif
 
 	/* Create an ICU message formatter. */
 	MSG_FORMAT_OBJECT(mfo) = umsg_open(spattern, spattern_len, slocale, NULL, &INTL_DATA_ERROR_CODE(mfo));
diff -urNapw php-5.4.4/ext/intl/resourcebundle/resourcebundle_class.c php-5.4.5/ext/intl/resourcebundle/resourcebundle_class.c
--- php-5.4.4/ext/intl/resourcebundle/resourcebundle_class.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/intl/resourcebundle/resourcebundle_class.c	2012-07-18 08:19:16.000000000 +0200
@@ -91,7 +91,7 @@ static void resourcebundle_ctor(INTERNAL
 
 	intl_error_reset( NULL TSRMLS_CC );
 
-	if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "ss|b", 
+	if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s!s!|b", 
 		&locale, &locale_len, &bundlename, &bundlename_len, &fallback ) == FAILURE )
 	{
 		intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR,
@@ -102,6 +102,10 @@ static void resourcebundle_ctor(INTERNAL
 
 	INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
 
+	if (locale == NULL) {
+		locale = INTL_G(default_locale);
+	}
+
 	if (fallback) {
 		rb->me = ures_open(bundlename, locale, &INTL_DATA_ERROR_CODE(rb));
 	} else {
@@ -110,10 +114,14 @@ static void resourcebundle_ctor(INTERNAL
 
 	INTL_CTOR_CHECK_STATUS(rb, "resourcebundle_ctor: Cannot load libICU resource bundle");
 
-	if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING || INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
+	if (!fallback && (INTL_DATA_ERROR_CODE(rb) == U_USING_FALLBACK_WARNING ||
+			INTL_DATA_ERROR_CODE(rb) == U_USING_DEFAULT_WARNING)) {
 		intl_errors_set_code( NULL, INTL_DATA_ERROR_CODE(rb) TSRMLS_CC );
-		spprintf( &pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource '%s' without fallback from %s to %s",
-				bundlename, locale, ures_getLocaleByType( rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)) );
+		spprintf(&pbuf, 0, "resourcebundle_ctor: Cannot load libICU resource "
+				"'%s' without fallback from %s to %s",
+				bundlename ? bundlename : "(default data)", locale,
+				ures_getLocaleByType(
+					rb->me, ULOC_ACTUAL_LOCALE, &INTL_DATA_ERROR_CODE(rb)));
 		intl_errors_set_custom_msg( INTL_DATA_ERROR_P(rb), pbuf, 1 TSRMLS_CC );
 		efree(pbuf);
 		zval_dtor( return_value );
@@ -427,6 +435,8 @@ void resourcebundle_register_class( TSRM
 	ResourceBundle_object_handlers.clone_obj	  = NULL; /* ICU ResourceBundle has no clone implementation */
 	ResourceBundle_object_handlers.read_dimension = resourcebundle_array_get;
 	ResourceBundle_object_handlers.count_elements = resourcebundle_array_count;
+
+	zend_class_implements(ResourceBundle_ce_ptr TSRMLS_CC, 1, zend_ce_traversable);
 }
 /* }}} */
 
diff -urNapw php-5.4.4/ext/json/json.c php-5.4.5/ext/json/json.c
--- php-5.4.4/ext/json/json.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/json/json.c	2012-07-18 08:19:16.000000000 +0200
@@ -351,6 +351,7 @@ static void json_escape_string(smart_str
 	int pos = 0, ulen = 0;
 	unsigned short us;
 	unsigned short *utf16;
+	size_t newlen;
 
 	if (len == 0) {
 		smart_str_appendl(buf, "\"\"", 2);
@@ -402,6 +403,8 @@ static void json_escape_string(smart_str
 		len = ulen;
 	}
 
+	/* pre-allocate for string length plus 2 quotes */
+	smart_str_alloc(buf, len+2, 0);
 	smart_str_appendc(buf, '"');
 
 	while (pos < len)
diff -urNapw php-5.4.4/ext/libxml/libxml.c php-5.4.5/ext/libxml/libxml.c
--- php-5.4.4/ext/libxml/libxml.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/libxml/libxml.c	2012-07-18 08:19:16.000000000 +0200
@@ -677,9 +677,18 @@ is_string:
 static xmlParserInputPtr _php_libxml_pre_ext_ent_loader(const char *URL,
 		const char *ID, xmlParserCtxtPtr context)
 {
+	TSRMLS_FETCH();
+
 	/* Check whether we're running in a PHP context, since the entity loader
-	 * we've defined is an application level (true global) setting */
-	if (xmlGenericError == php_libxml_error_handler) {
+	 * we've defined is an application level (true global) setting.
+	 * If we are, we also want to check whether we've finished activating
+	 * the modules (RINIT phase). Using our external entity loader during a
+	 * RINIT should not be problem per se (though during MINIT it is, because
+	 * we don't even have a resource list by then), but then whether one
+	 * extension would be using the custom external entity loader or not
+	 * could depend on extension loading order
+	 * (if _php_libxml_per_request_initialization */
+	if (xmlGenericError == php_libxml_error_handler && PG(modules_activated)) {
 		return _php_libxml_external_entity_loader(URL, ID, context);
 	} else {
 		return _php_libxml_default_entity_loader(URL, ID, context);
diff -urNapw php-5.4.4/ext/mysqlnd/mysqlnd.c php-5.4.5/ext/mysqlnd/mysqlnd.c
--- php-5.4.4/ext/mysqlnd/mysqlnd.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/mysqlnd/mysqlnd.c	2012-07-18 08:19:16.000000000 +0200
@@ -764,6 +764,13 @@ MYSQLND_METHOD(mysqlnd_conn_data, connec
 	conn->server_version	= mnd_pestrdup(greet_packet->server_version, conn->persistent);
 
 	conn->greet_charset = mysqlnd_find_charset_nr(greet_packet->charset_no);
+	if (!conn->greet_charset) {
+		php_error_docref(NULL TSRMLS_CC, E_WARNING,
+			"Server sent charset (%d) unknown to the client. Please, report to the developers", greet_packet->charset_no);
+		SET_CLIENT_ERROR(*conn->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE,
+			"Server sent charset unknown to the client. Please, report to the developers");
+		goto err;
+	}
 	/* we allow load data local infile by default */
 	mysql_flags |= MYSQLND_CAPABILITIES;
 
diff -urNapw php-5.4.4/ext/mysqlnd/mysqlnd_ps.c php-5.4.5/ext/mysqlnd/mysqlnd_ps.c
--- php-5.4.4/ext/mysqlnd/mysqlnd_ps.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/mysqlnd/mysqlnd_ps.c	2012-07-18 08:19:16.000000000 +0200
@@ -636,6 +636,8 @@ MYSQLND_METHOD(mysqlnd_stmt, execute)(MY
 		  have it again.
 		*/
 		stmt->result->m.free_result_buffers(stmt->result TSRMLS_CC);
+
+		stmt->state = MYSQLND_STMT_PREPARED;
 	} else if (stmt->state < MYSQLND_STMT_PREPARED) {
 		/* Only initted - error */
 		SET_CLIENT_ERROR(*conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE,
@@ -1221,8 +1223,6 @@ MYSQLND_METHOD(mysqlnd_stmt, reset)(MYSQ
 			COPY_CLIENT_ERROR(*stmt->error_info, *conn->error_info);
 		}
 		*stmt->upsert_status = *conn->upsert_status;
-
-		stmt->state = MYSQLND_STMT_PREPARED;
 	}
 	DBG_INF(ret == PASS? "PASS":"FAIL");
 	DBG_RETURN(ret);
@@ -1261,8 +1261,6 @@ MYSQLND_METHOD(mysqlnd_stmt, flush)(MYSQ
 				stmt->result->m.skip_result(stmt->result TSRMLS_CC);
 			}
 		} while (mysqlnd_stmt_more_results(s) && mysqlnd_stmt_next_result(s) == PASS);
-
-		stmt->state = MYSQLND_STMT_PREPARED;
 	}
 	DBG_INF(ret == PASS? "PASS":"FAIL");
 	DBG_RETURN(ret);
diff -urNapw php-5.4.4/ext/pdo_sqlite/sqlite_driver.c php-5.4.5/ext/pdo_sqlite/sqlite_driver.c
--- php-5.4.4/ext/pdo_sqlite/sqlite_driver.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/pdo_sqlite/sqlite_driver.c	2012-07-18 08:19:16.000000000 +0200
@@ -760,7 +760,7 @@ static struct pdo_dbh_methods sqlite_met
 
 static char *make_filename_safe(const char *filename TSRMLS_DC)
 {
-	if (*filename && strncmp(filename, ":memory:", sizeof(":memory:")-1)) {
+	if (*filename && memcmp(filename, ":memory:", sizeof(":memory:"))) {
 		char *fullpath = expand_filepath(filename, NULL TSRMLS_CC);
 
 		if (!fullpath) {
diff -urNapw php-5.4.4/ext/phar/cgidebug php-5.4.5/ext/phar/cgidebug
--- php-5.4.4/ext/phar/cgidebug	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/phar/cgidebug	1970-01-01 01:00:00.000000000 +0100
@@ -1,11 +0,0 @@
-#!/bin/sh
-export SCRIPT_NAME=/front.phar.php
-export PATH_INFO=/index.php
-export SCRIPT_FILENAME=/home/cellog/workspace/php5/ext/phar/tests/front.phar.php
-export PATH_TRANSLATED=/home/cellog/workspace/php5/ext/phar/tests/front.phar.php
-export REDIRECT_STATUS=1
-export REQUEST_METHOD=GET
-export REQUEST_URI=/front.phar.php/index.php
-cd /home/cellog/workspace/php5
-ddd sapi/cgi/php-cgi &
-cd /home/cellog/workspace/php5/ext/phar
diff -urNapw php-5.4.4/ext/phar/package.php php-5.4.5/ext/phar/package.php
--- php-5.4.4/ext/phar/package.php	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/phar/package.php	1970-01-01 01:00:00.000000000 +0100
@@ -1,139 +0,0 @@
-<?php
-
-$notes = '
-BC BREAKING RELEASE
- BC breaks:
- * Phar object Compression API is rewritten.  Use Phar::compress() and decompress(),
-   Phar::compressFiles()/decompressFiles() and PharFileInfo->compress()/decompress().
- * phar.extract_list and Phar::getExtractList() are removed
-
-Major feature functionality release
- * phar.cache_list allows web-based phar applications to run at equal or faster than
-   their on-disk equivalent [Greg]
- * new default stub allows running of phar-based phars without phar extension [Greg/Steph]
- * add support for tar-based and zip-based phar archives [Greg]
- * add support for OpenSSL-based true signatures [Greg]
- * add support for signatures to tar-based phar archives [Greg]
- * add Phar::isFileFormat() [Greg]
- * add Phar::convertToExecutable(), Phar::convertToData() [Greg]
- * add Phar::compress() [Greg]
- * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to
-   decompressFiles() [Greg]
- * conversion to compressed or to other file formats automatically copies the archive
-   to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph]
- * add Phar::webPhar() for running a web-based application unmodified
-   directly from a phar archive [Greg]
- * file functions (fopen-based and stat-based) can be instructed to only look for
-   relative paths within a phar via Phar::interceptFileFuncs()
- * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph]
-   non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg]
- * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg]
- * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg]
- * add option to compress the entire phar file for phar/tar file format [Greg]
- * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg]
- * implement Phar::copy(string $from, string $to) [Greg]
- * implement Phar::running(), returns path or URL to currently executed phar
- * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg]
- * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph]
- * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg]
- * add Phar::delete() [Greg]
- * implement Phar::unlinkArchive() [Greg]
-
-Security addition
- * aliases are validated so that they contain no directory separators as intended
- * on conversion to other formats, user-supplied aliases are validated
-
-Changes since 2.0.0RC2:
- fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in
- getSignature() call
- fixed PHP Bug #49020: phar misinterprets ustar long filename standard
- fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed
- fixed PHP Bug #48791: open office files always reported as corrupted
- fixed PHP Bug #48783: make install will fail saying phar file exists
- fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location
- fixed PHP Bug #48681: openssl signature verification for tar archives broken
- fixed PHP Bug #48377: error message unclear on converting phar with existing file
- fixed isset() on sub-directories (isset("blah") if file "blah/foo.php" exists)
-
- make phar work in PHP 6
-Changes since 2.0.0RC1:
- security vulnerability in handling of long tar filenames fixed
- fixed PECL Bug #14646: phar error message unclear with php stream wrappers
- fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}()
- fixed PHP Bug #48257: PharData throws an exception with non-phar tar
- fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist
- fixed PHP Bug #46032: PharData::__construct() - wrong memory read
- fixed PHP Bug #46060: Phar::addEmptyDir() breaks
- fixed PHP Bug #45907: undefined reference to \'PHP_SHA512Init\'
- fixed PHP Bug #45726: PHP_Archive / Archive.php missing
-Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored,
- conversion API refactored
-Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes
- implement OpenSSL asynchronous true package signing
- add support for package signing to tar-based archives
- require PHP 5.2.1+
-';
-
-if (!class_exists("Phar") && !extension_loaded("Phar")) {
-	die("Extension phar not present");
-}
-error_reporting(E_ALL & ~E_DEPRECATED);
-
-require_once 'PEAR/PackageFileManager2.php';
-
-PEAR::setErrorHandling(PEAR_ERROR_DIE);
-
-$options = array(
-	'filelistgenerator' => 'svn',
-	'changelogoldtonew' => false,
-	'simpleoutput'      => true,
-	'baseinstalldir'    => '/',
-	'packagedirectory'  => dirname(__FILE__),
-	'packagefile'       => 'package.xml',
-	'clearcontents'     => true,
-	'ignore'            => array('package*.php', 'package*.xml'),
-	'dir_roles'         => array(
-		 'docs'         => 'doc',
-		 'examples'     => 'doc',
-		 'tests'        => 'test',
-		 'phar'         => 'src',
-	),
-	'exceptions'        => array(
-		 'CREDITS'            => 'doc',
-		 'EXPERIMENTAL'       => 'doc',
-		 'LICENSE'            => 'doc',
-		 'Makefile.frag'      => 'src',
-		 'phar_path_check.re' => 'src',
-		 'TODO'               => 'doc',
-		 'phar.phar'          => 'script',
-	),
-);
-
-$package = PEAR_PackageFileManager2::importOptions(dirname(__FILE__) . '/package.xml', $options);
-
-$package->clearDeps();
-$package->setPhpDep('5.2.1');
-$package->setPearInstallerDep('1.4.3');
-$package->addPackageDepWithChannel('optional', 'bz2', 'pecl.php.net', false, false, false, false, 'bz2');
-// all this false business sets the <providesextension> tag that allows us to have hash built
-// in statically
-$package->addPackageDepWithChannel('optional', 'hash', 'pecl.php.net', false, false, false, false, 'hash');
-$package->addExtensionDep('optional', 'spl');
-$package->addExtensionDep('optional', 'zlib');
-$package->setPackageType('extsrc');
-$package->addRelease();
-$package->setReleaseVersion(phpversion('phar'));
-$package->setAPIVersion(Phar::apiVersion());
-$package->setReleaseStability('stable');
-$package->setAPIStability('stable');
-$package->setNotes("\n$notes\n");
-//$package->addGlobalReplacement('package-info', '@package_version@', 'version');
-$package->generateContents();
-
-if (isset($_GET['make']) || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')) {
-	$package->writePackageFile();
-} else {
-	$package->debugPackageFile();
-}
-
-?>
diff -urNapw php-5.4.4/ext/phar/package.xml php-5.4.5/ext/phar/package.xml
--- php-5.4.4/ext/phar/package.xml	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/phar/package.xml	2012-07-18 08:19:16.000000000 +0200
@@ -941,7 +941,6 @@ Changes since 2.0.0b1: addition of phar.
     <file name="zf_test.phpt" role="test" />
    </dir> <!-- /tests -->
    <file name="build_precommand.php" role="php" />
-   <file name="cgidebug" role="data" />
    <file name="config.m4" role="src" />
    <file name="config.w32" role="src" />
    <file name="CREDITS" role="doc" />
diff -urNapw php-5.4.4/ext/readline/readline.c php-5.4.5/ext/readline/readline.c
--- php-5.4.4/ext/readline/readline.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/readline/readline.c	2012-07-18 08:19:16.000000000 +0200
@@ -198,7 +198,7 @@ PHP_RSHUTDOWN_FUNCTION(readline)
 
 PHP_MINFO_FUNCTION(readline)
 {
-	return PHP_MINFO(cli_readline)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
+	PHP_MINFO(cli_readline)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
 }
 
 /* }}} */
diff -urNapw php-5.4.4/ext/reflection/php_reflection.c php-5.4.5/ext/reflection/php_reflection.c
--- php-5.4.4/ext/reflection/php_reflection.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/reflection/php_reflection.c	2012-07-18 08:19:16.000000000 +0200
@@ -2561,7 +2561,8 @@ ZEND_METHOD(reflection_parameter, getDef
 
 	*return_value = *precv->op2.zv;
 	INIT_PZVAL(return_value);
-	if (Z_TYPE_P(return_value) != IS_CONSTANT && Z_TYPE_P(return_value) != IS_CONSTANT_ARRAY) {
+	if ((Z_TYPE_P(return_value) & IS_CONSTANT_TYPE_MASK) != IS_CONSTANT
+			&& (Z_TYPE_P(return_value) & IS_CONSTANT_TYPE_MASK) != IS_CONSTANT_ARRAY) {
 		zval_copy_ctor(return_value);
 	}
 	zval_update_constant_ex(&return_value, (void*)0, param->fptr->common.scope TSRMLS_CC);
@@ -2923,6 +2924,14 @@ ZEND_METHOD(reflection_method, invokeArg
 	fcc.called_scope = intern->ce;
 	fcc.object_ptr = object;
 
+	/* 
+	 * Copy the zend_function when calling via handler (e.g. Closure::__invoke())
+	 */
+	if (mptr->type == ZEND_INTERNAL_FUNCTION &&
+		(mptr->internal_function.fn_flags & ZEND_ACC_CALL_VIA_HANDLER) != 0) {
+		fcc.function_handler = _copy_function(mptr TSRMLS_CC);
+	}
+
 	result = zend_call_function(&fci, &fcc TSRMLS_CC);
 
 	efree(params);
@@ -6072,7 +6081,7 @@ PHP_MINFO_FUNCTION(reflection) /* {{{ */
 	php_info_print_table_start();
 	php_info_print_table_header(2, "Reflection", "enabled");
 
-	php_info_print_table_row(2, "Version", "$Id: 1cf65cee164ed57874ce2d29e5c46b82f6139524 $");
+	php_info_print_table_row(2, "Version", "$Id: ee76afbc02b3063f63d87c9d9729b509ac9e10cf $");
 
 	php_info_print_table_end();
 } /* }}} */
diff -urNapw php-5.4.4/ext/sockets/config.m4 php-5.4.5/ext/sockets/config.m4
--- php-5.4.4/ext/sockets/config.m4	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/sockets/config.m4	2012-07-18 08:19:16.000000000 +0200
@@ -28,6 +28,21 @@ if test "$PHP_SOCKETS" != "no"; then
   )
   AC_DEFINE([HAVE_SOCKETS], 1, [ ])
 
+  dnl Check for fied ss_family in sockaddr_storage (missing in AIX until 5.3)
+  AC_CACHE_CHECK([for field ss_family in struct sockaddr_storage], ac_cv_ss_family,
+  [
+    AC_TRY_COMPILE([
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netdb.h>
+  ], [struct sockaddr_storage sa_store; sa_store.ss_family = AF_INET6;],
+     ac_cv_ss_family=yes, ac_cv_ss_family=no)
+  ])
+  
+  if test "$ac_cv_ss_family" = yes; then
+    AC_DEFINE(HAVE_SA_SS_FAMILY,1,[Whether you have sockaddr_storage.ss_family])
+  fi
+
   PHP_NEW_EXTENSION([sockets], [sockets.c multicast.c], [$ext_shared])
   PHP_INSTALL_HEADERS([ext/sockets/], [php_sockets.h])
 fi
diff -urNapw php-5.4.4/ext/sockets/sockets.c php-5.4.5/ext/sockets/sockets.c
--- php-5.4.4/ext/sockets/sockets.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/sockets/sockets.c	2012-07-18 08:19:16.000000000 +0200
@@ -77,6 +77,9 @@
 # define IS_INVALID_SOCKET(a)	(a->bsd_socket < 0)
 # define set_errno(a) (errno = a)
 # include "php_sockets.h"
+# if defined(_AIX) && !defined(HAVE_SA_SS_FAMILY)
+# define ss_family __ss_family
+# endif
 # if HAVE_IF_NAMETOINDEX
 #  include <net/if.h>
 # endif
diff -urNapw php-5.4.4/ext/spl/spl_array.c php-5.4.5/ext/spl/spl_array.c
--- php-5.4.4/ext/spl/spl_array.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/spl/spl_array.c	2012-07-18 08:19:16.000000000 +0200
@@ -1943,6 +1943,7 @@ PHP_MINIT_FUNCTION(spl_array)
 	REGISTER_SPL_IMPLEMENTS(ArrayObject, Aggregate);
 	REGISTER_SPL_IMPLEMENTS(ArrayObject, ArrayAccess);
 	REGISTER_SPL_IMPLEMENTS(ArrayObject, Serializable);
+	REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable);
 	memcpy(&spl_handler_ArrayObject, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
 
 	spl_handler_ArrayObject.clone_obj = spl_array_object_clone;
@@ -1967,6 +1968,7 @@ PHP_MINIT_FUNCTION(spl_array)
 	REGISTER_SPL_IMPLEMENTS(ArrayIterator, ArrayAccess);
 	REGISTER_SPL_IMPLEMENTS(ArrayIterator, SeekableIterator);
 	REGISTER_SPL_IMPLEMENTS(ArrayIterator, Serializable);
+	REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable);
 	memcpy(&spl_handler_ArrayIterator, &spl_handler_ArrayObject, sizeof(zend_object_handlers));
 	spl_ce_ArrayIterator->get_iterator = spl_array_get_iterator;
 	
@@ -1974,9 +1976,6 @@ PHP_MINIT_FUNCTION(spl_array)
 	REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
 	spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator;
 
-	REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable);
-	REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable);
-
 	REGISTER_SPL_CLASS_CONST_LONG(ArrayObject,   "STD_PROP_LIST",    SPL_ARRAY_STD_PROP_LIST);
 	REGISTER_SPL_CLASS_CONST_LONG(ArrayObject,   "ARRAY_AS_PROPS",   SPL_ARRAY_ARRAY_AS_PROPS);
 
diff -urNapw php-5.4.4/ext/spl/spl_directory.c php-5.4.5/ext/spl/spl_directory.c
--- php-5.4.4/ext/spl/spl_directory.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/spl/spl_directory.c	2012-07-18 08:19:16.000000000 +0200
@@ -1432,6 +1432,7 @@ SPL_METHOD(FilesystemIterator, __constru
 SPL_METHOD(FilesystemIterator, rewind)
 {
 	spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+	int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
 
 	if (zend_parse_parameters_none() == FAILURE) {
 		return;
@@ -1443,7 +1444,7 @@ SPL_METHOD(FilesystemIterator, rewind)
 	}
 	do {
 		spl_filesystem_dir_read(intern TSRMLS_CC);
-	} while (spl_filesystem_is_dot(intern->u.dir.entry.d_name));
+	} while (skip_dots && spl_filesystem_is_dot(intern->u.dir.entry.d_name));
 }
 /* }}} */
 
diff -urNapw php-5.4.4/ext/spl/spl_heap.c php-5.4.5/ext/spl/spl_heap.c
--- php-5.4.4/ext/spl/spl_heap.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/spl/spl_heap.c	2012-07-18 08:19:16.000000000 +0200
@@ -953,7 +953,7 @@ static int spl_heap_it_get_current_key(z
 {
 	spl_heap_it *iterator = (spl_heap_it *)iter;
 
-	*int_key = (ulong) iterator->object->heap->count;
+	*int_key = (ulong) iterator->object->heap->count - 1;
 	return HASH_KEY_IS_LONG;
 }
 /* }}} */
diff -urNapw php-5.4.4/ext/sqlite3/sqlite3.c php-5.4.5/ext/sqlite3/sqlite3.c
--- php-5.4.4/ext/sqlite3/sqlite3.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/sqlite3/sqlite3.c	2012-07-18 08:19:16.000000000 +0200
@@ -114,7 +114,10 @@ PHP_METHOD(sqlite3, open)
 		zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Already initialised DB Object", 0 TSRMLS_CC);
 	}
 
-	if (strncmp(filename, ":memory:", 8) != 0) {
+	if (strlen(filename) != filename_len) {
+		return;
+	}
+	if (memcmp(filename, ":memory:", sizeof(":memory:")) != 0) {
 		if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
 			zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Unable to expand filepath", 0 TSRMLS_CC);
 			return;
@@ -1959,7 +1962,7 @@ static int php_sqlite3_authorizer(void *
 	switch (access_type) {
 		case SQLITE_ATTACH:
 		{
-			if (strncmp(arg3, ":memory:", sizeof(":memory:")-1) && *arg3) {
+			if (memcmp(arg3, ":memory:", sizeof(":memory:")) && *arg3) {
 				TSRMLS_FETCH();
 
 #if PHP_API_VERSION < 20100412
diff -urNapw php-5.4.4/ext/standard/base64.c php-5.4.5/ext/standard/base64.c
--- php-5.4.4/ext/standard/base64.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/standard/base64.c	2012-07-18 08:19:16.000000000 +0200
@@ -59,14 +59,14 @@ PHPAPI unsigned char *php_base64_encode(
 	unsigned char *p;
 	unsigned char *result;
 
-	if ((length + 2) < 0 || ((length + 2) / 3) >= (1 << (sizeof(int) * 8 - 2))) {
+	if (length < 0) {
 		if (ret_length != NULL) {
 			*ret_length = 0;
 		}
 		return NULL;
 	}
 
-	result = (unsigned char *)safe_emalloc(((length + 2) / 3) * 4, sizeof(char), 1);
+	result = (unsigned char *) safe_emalloc((length + 2) / 3, 4 * sizeof(char), 1);
 	p = result;
 
 	while (length > 2) { /* keep going until we have less than 24 bits */
diff -urNapw php-5.4.4/ext/standard/crypt.c php-5.4.5/ext/standard/crypt.c
--- php-5.4.4/ext/standard/crypt.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/standard/crypt.c	2012-07-18 08:19:16.000000000 +0200
@@ -199,7 +199,7 @@ PHP_FUNCTION(crypt)
 			char *output;
 			int needed = (sizeof(sha512_salt_prefix) - 1
 						+ sizeof(sha512_rounds_prefix) + 9 + 1
-						+ strlen(salt) + 1 + 43 + 1);
+						+ salt_in_len + 1 + 86 + 1);
 			output = emalloc(needed);
 			salt[salt_in_len] = '\0';
 
@@ -214,7 +214,7 @@ PHP_FUNCTION(crypt)
 				RETVAL_STRING(output, 1);
 			}
 
-			memset(output, 0, PHP_MAX_SALT_LEN + 1);
+			memset(output, 0, needed);
 			efree(output);
 		} else if (salt[0]=='$' && salt[1]=='5' && salt[2]=='$') {
 			const char sha256_salt_prefix[] = "$5$";
@@ -222,7 +222,7 @@ PHP_FUNCTION(crypt)
 			char *output;
 			int needed = (sizeof(sha256_salt_prefix) - 1
 						+ sizeof(sha256_rounds_prefix) + 9 + 1
-						+ strlen(salt) + 1 + 43 + 1);
+						+ salt_in_len + 1 + 43 + 1);
 			output = emalloc(needed);
 			salt[salt_in_len] = '\0';
 
@@ -237,7 +237,7 @@ PHP_FUNCTION(crypt)
 				RETVAL_STRING(output, 1);
 			}
 
-			memset(output, 0, PHP_MAX_SALT_LEN + 1);
+			memset(output, 0, needed);
 			efree(output);
 		} else if (
 				salt[0] == '$' &&
diff -urNapw php-5.4.4/ext/standard/var.c php-5.4.5/ext/standard/var.c
--- php-5.4.4/ext/standard/var.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/standard/var.c	2012-07-18 08:19:16.000000000 +0200
@@ -541,12 +541,9 @@ static inline int php_add_var_hash(HashT
 
 	/* relies on "(long)" being a perfect hash function for data pointers,
 	 * however the actual identity of an object has had to be determined
-	 * by its object handle and the class entry since 5.0. */
+	 * by its object handle since 5.0. */
 	if ((Z_TYPE_P(var) == IS_OBJECT) && Z_OBJ_HT_P(var)->get_class_entry) {
-		p = smart_str_print_long(id + sizeof(id) - 1,
-				(((size_t)Z_OBJCE_P(var) << 5)
-				| ((size_t)Z_OBJCE_P(var) >> (sizeof(long) * 8 - 5)))
-				+ (long) Z_OBJ_HANDLE_P(var));
+		p = smart_str_print_long(id + sizeof(id) - 1, (long) Z_OBJ_HANDLE_P(var));
 		*(--p) = 'O';
 		len = id + sizeof(id) - 1 - p;
 	} else {
diff -urNapw php-5.4.4/ext/xmlwriter/php_xmlwriter.c php-5.4.5/ext/xmlwriter/php_xmlwriter.c
--- php-5.4.4/ext/xmlwriter/php_xmlwriter.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/xmlwriter/php_xmlwriter.c	2012-07-18 08:19:16.000000000 +0200
@@ -614,6 +614,7 @@ static char *_xmlwriter_get_valid_file_p
 		/* absolute file uris - libxml only supports localhost or empty host */
 		if (strncasecmp(source, "file:///", 8) == 0) {
 			if (source[sizeof("file:///") - 1] == '\0') {
+				xmlFreeURI(uri);
 				return NULL;
 			}
 			isFileUri = 1;
@@ -624,6 +625,7 @@ static char *_xmlwriter_get_valid_file_p
 #endif
 		} else if (strncasecmp(source, "file://localhost/",17) == 0) {
 			if (source[sizeof("file://localhost/") - 1] == '\0') {
+				xmlFreeURI(uri);
 				return NULL;
 			}
 
diff -urNapw php-5.4.4/ext/zip/config.m4 php-5.4.5/ext/zip/config.m4
--- php-5.4.4/ext/zip/config.m4	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/zip/config.m4	2012-07-18 08:19:16.000000000 +0200
@@ -89,7 +89,14 @@ yes
                          lib/zip_new.c lib/zip_source_file.c lib/zip_stat_index.c \
                          lib/zip_set_archive_comment.c lib/zip_set_file_comment.c \
                          lib/zip_unchange_archive.c lib/zip_memdup.c lib/zip_stat_init.c lib/zip_add_dir.c \
-                         lib/zip_error_clear.c lib/zip_file_error_clear.c"
+                         lib/zip_error_clear.c lib/zip_file_error_clear.c \
+						 lib/zip_fdopen.c lib/zip_fopen_encrypted.c lib/zip_fopen_index_encrypted.c \
+						 lib/zip_get_compression_implementation.c lib/zip_get_encryption_implementation.c \
+						 lib/zip_get_file_extra.c lib/zip_get_num_entries.c lib/zip_set_default_password.c \
+						 lib/zip_set_file_extra.c lib/zip_source_close.c lib/zip_source_crc.c \
+						 lib/zip_source_deflate.c lib/zip_source_error.c lib/zip_source_layered.c \
+						 lib/zip_source_open.c lib/zip_source_pkware.c lib/zip_source_pop.c \
+						 lib/zip_source_read.c lib/zip_source_stat.c"
 
   AC_DEFINE(HAVE_ZIP,1,[ ])
   PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
diff -urNapw php-5.4.4/ext/zip/config.w32 php-5.4.5/ext/zip/config.w32
--- php-5.4.4/ext/zip/config.w32	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/zip/config.w32	2012-07-18 08:19:16.000000000 +0200
@@ -27,7 +27,14 @@ if (PHP_ZIP != "no") {
                      zip_get_archive_comment.c zip_get_file_comment.c \
                      zip_set_archive_comment.c zip_set_file_comment.c \
                      zip_unchange_archive.c zip_memdup.c zip_stat_init.c \
-                     zip_add_dir.c zip_file_error_clear.c zip_error_clear.c", "zip");
+                     zip_add_dir.c zip_file_error_clear.c zip_error_clear.c \
+                     zip_fdopen.c zip_fopen_encrypted.c zip_fopen_index_encrypted.c \
+                     zip_get_compression_implementation.c zip_get_encryption_implementation.c \
+                     zip_get_file_extra.c zip_get_num_entries.c zip_set_default_password.c \
+                     zip_set_file_extra.c zip_source_close.c zip_source_crc.c \
+                     zip_source_deflate.c zip_source_error.c zip_source_layered.c \
+                     zip_source_open.c zip_source_pkware.c zip_source_pop.c \
+                     zip_source_read.c zip_source_stat.c", "zip");
 
 		AC_DEFINE('HAVE_ZIP', 1);
 	} else {
diff -urNapw php-5.4.4/ext/zip/php_zip.c php-5.4.5/ext/zip/php_zip.c
--- php-5.4.4/ext/zip/php_zip.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/zip/php_zip.c	2012-07-18 08:19:16.000000000 +0200
@@ -1152,7 +1152,13 @@ static void php_zip_free_entry(zend_rsrc
 
 	if (zr_rsrc) {
 		if (zr_rsrc->zf) {
+			if (zr_rsrc->zf->za) {
 			zip_fclose(zr_rsrc->zf);
+			} else {
+				if (zr_rsrc->zf->src)
+					zip_source_free(zr_rsrc->zf->src);
+				free(zr_rsrc->zf);
+			}
 			zr_rsrc->zf = NULL;
 		}
 		efree(zr_rsrc);
@@ -1334,8 +1339,8 @@ static PHP_NAMED_FUNCTION(zif_zip_entry_
 	}
 
 	ZEND_FETCH_RESOURCE(zr_rsrc, zip_read_rsrc *, &zip_entry, -1, le_zip_entry_name, le_zip_entry);
-	/*  we got a zip_entry resource, be happy */
-	RETURN_TRUE;
+
+	RETURN_BOOL(SUCCESS == zend_list_delete(Z_LVAL_P(zip_entry)));
 }
 /* }}} */
 
@@ -2863,7 +2868,7 @@ static PHP_MINFO_FUNCTION(zip)
 	php_info_print_table_row(2, "Zip", "enabled");
 	php_info_print_table_row(2, "Extension Version","$Id$");
 	php_info_print_table_row(2, "Zip version", PHP_ZIP_VERSION_STRING);
-	php_info_print_table_row(2, "Libzip version", "0.9.0");
+	php_info_print_table_row(2, "Libzip version", LIBZIP_VERSION);
 
 	php_info_print_table_end();
 }
diff -urNapw php-5.4.4/ext/zip/php_zip.h php-5.4.5/ext/zip/php_zip.h
--- php-5.4.4/ext/zip/php_zip.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/ext/zip/php_zip.h	2012-07-18 08:19:16.000000000 +0200
@@ -30,7 +30,7 @@ extern zend_module_entry zip_module_entr
 
 #include "lib/zip.h"
 
-#define PHP_ZIP_VERSION_STRING "1.9.1"
+#define PHP_ZIP_VERSION_STRING "1.11.0"
 
 #if ((PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 2) || PHP_MAJOR_VERSION >= 6)
 # define PHP_ZIP_USE_OO 1
diff -urNapw php-5.4.4/main/php_config.h.in php-5.4.5/main/php_config.h.in
--- php-5.4.4/main/php_config.h.in	2012-06-13 08:08:08.000000000 +0200
+++ php-5.4.5/main/php_config.h.in	2012-07-18 09:27:09.000000000 +0200
@@ -1498,6 +1498,9 @@
 /* */
 #undef HAVE_SAPDB
 
+/* Whether you have sockaddr_storage.ss_family */
+#undef HAVE_SA_SS_FAMILY
+
 /* Define to 1 if you have the `scandir' function. */
 #undef HAVE_SCANDIR
 
diff -urNapw php-5.4.4/main/php_version.h php-5.4.5/main/php_version.h
--- php-5.4.4/main/php_version.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/main/php_version.h	2012-07-18 08:19:16.000000000 +0200
@@ -2,7 +2,7 @@
 /* edit configure.in to change version number */
 #define PHP_MAJOR_VERSION 5
 #define PHP_MINOR_VERSION 4
-#define PHP_RELEASE_VERSION 4
+#define PHP_RELEASE_VERSION 5
 #define PHP_EXTRA_VERSION ""
-#define PHP_VERSION "5.4.4"
-#define PHP_VERSION_ID 50404
+#define PHP_VERSION "5.4.5"
+#define PHP_VERSION_ID 50405
diff -urNapw php-5.4.4/main/streams/streams.c php-5.4.5/main/streams/streams.c
--- php-5.4.4/main/streams/streams.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/main/streams/streams.c	2012-07-18 08:19:16.000000000 +0200
@@ -2332,8 +2332,8 @@ PHPAPI int _php_stream_scandir(char *dir
 	php_stream *stream;
 	php_stream_dirent sdp;
 	char **vector = NULL;
-	int vector_size = 0;
-	int nfiles = 0;
+	unsigned int vector_size = 0;
+	unsigned int nfiles = 0;
 
 	if (!namelist) {
 		return FAILURE;
@@ -2349,14 +2349,24 @@ PHPAPI int _php_stream_scandir(char *dir
 			if (vector_size == 0) {
 				vector_size = 10;
 			} else {
+				if(vector_size*2 < vector_size) {
+					/* overflow */
+					efree(vector);
+					return FAILURE;
+				}
 				vector_size *= 2;
 			}
-			vector = (char **) erealloc(vector, vector_size * sizeof(char *));
+			vector = (char **) safe_erealloc(vector, vector_size, sizeof(char *), 0);
 		}
 
 		vector[nfiles] = estrdup(sdp.d_name);
 
 		nfiles++;
+		if(vector_size < 10 || nfiles == 0) {
+			/* overflow */
+			efree(vector);
+			return FAILURE;
+		}
 	}
 	php_stream_closedir(stream);
 
diff -urNapw php-5.4.4/makedist php-5.4.5/makedist
--- php-5.4.4/makedist	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/makedist	2012-07-18 08:19:16.000000000 +0200
@@ -69,9 +69,6 @@ echo ""
 
 cd $DIR || exit 5
 
-# The full ChangeLog is available separately from lxr.php.net
-rm -f ChangeLog*
-
 # hide away our own versions of libtool-generated files
 for i in $LT_TARGETS; do
   if test -f "$i"; then
diff -urNapw php-5.4.4/run-tests.php php-5.4.5/run-tests.php
--- php-5.4.4/run-tests.php	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/run-tests.php	2012-07-18 08:19:16.000000000 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/php
+#!/usr/bin/env php
 <?php
 /*
    +----------------------------------------------------------------------+
@@ -239,10 +239,7 @@ $ini_overwrites = array(
 		'magic_quotes_runtime=0',
 		'ignore_repeated_errors=0',
 		'precision=14',
-		'unicode.runtime_encoding=ISO-8859-1',
-		'unicode.script_encoding=UTF-8',
-		'unicode.output_encoding=UTF-8',
-		'unicode.from_error_mode=U_INVALID_SUBSTITUTE',
+		'memory_limit=128M',
 	);
 
 function write_information($show_html)
@@ -2093,7 +2090,9 @@ $output
 		$php = $old_php;
 	}
 
-	junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, "<![CDATA[\n " . preg_replace('/\e/', '<esc>', $diff) . "\n]]>");
+	$diff = empty($diff) ? '' : "<![CDATA[\n " . preg_replace('/\e/', '<esc>', $diff) . "\n]]>";
+
+	junit_mark_test_as($restype, str_replace($cwd . '/', '', $tested_file), $tested, null, $info, $diff);
 
 	return $restype[0] . 'ED';
 }
diff -urNapw php-5.4.4/sapi/cli/php_cli.c php-5.4.5/sapi/cli/php_cli.c
--- php-5.4.4/sapi/cli/php_cli.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/cli/php_cli.c	2012-07-18 08:19:16.000000000 +0200
@@ -1173,6 +1173,9 @@ out:
 	if (request_started) {
 		php_request_shutdown((void *) 0);
 	}
+	if (translated_path) {
+		free(translated_path);
+	}
 	return exit_status;
 err:
 	sapi_deactivate(TSRMLS_C);
diff -urNapw php-5.4.4/sapi/cli/php_cli_server.c php-5.4.5/sapi/cli/php_cli_server.c
--- php-5.4.4/sapi/cli/php_cli_server.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/cli/php_cli_server.c	2012-07-18 08:19:16.000000000 +0200
@@ -1826,6 +1826,9 @@ static int php_cli_server_send_error_pag
 	return SUCCESS;
 
 fail:
+	if (errstr) {
+		pefree(errstr, 1);
+	}
 	efree(escaped_request_uri);
 	return FAILURE;
 } /* }}} */
diff -urNapw php-5.4.4/sapi/fpm/config.m4 php-5.4.5/sapi/fpm/config.m4
--- php-5.4.4/sapi/fpm/config.m4	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/config.m4	2012-07-18 08:19:16.000000000 +0200
@@ -16,6 +16,7 @@ AC_DEFUN([AC_FPM_STDLIBS],
   AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h])
   AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/time.h])
   AC_CHECK_HEADERS([arpa/inet.h netinet/in.h])
+  AC_CHECK_HEADERS([sysexits.h])
 ])
 
 AC_DEFUN([AC_FPM_PRCTL],
@@ -192,6 +193,8 @@ AC_DEFUN([AC_FPM_TRACE],
       have_ptrace=no
       have_broken_ptrace=yes
       AC_MSG_RESULT([no])
+    ], [
+      AC_MSG_RESULT([skipped (cross compiling)])
     ])
   fi
 
@@ -264,6 +267,8 @@ AC_DEFUN([AC_FPM_TRACE],
     ], [
       proc_mem_file=""
       AC_MSG_RESULT([no])
+    ], [
+      AC_MSG_RESULT([skipped (cross compiling)])
     ])
   fi
   
diff -urNapw php-5.4.4/sapi/fpm/fpm/fastcgi.c php-5.4.5/sapi/fpm/fpm/fastcgi.c
--- php-5.4.4/sapi/fpm/fpm/fastcgi.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fastcgi.c	2012-07-18 08:19:16.000000000 +0200
@@ -427,7 +427,7 @@ static int fcgi_get_params(fcgi_request
 	char *tmp = buf;
 	size_t buf_size = sizeof(buf);
 	int name_len, val_len;
-	uint eff_name_len, eff_val_len;
+	uint eff_name_len;
 	char *s;
 	int ret = 1;
 	size_t bytes_consumed;
@@ -453,8 +453,12 @@ static int fcgi_get_params(fcgi_request
 			ret = 0;
 			break;
 		}
-		if (!fcgi_param_get_eff_len(p, p+name_len, &eff_name_len) ||
-		    !fcgi_param_get_eff_len(p+name_len, p+name_len+val_len, &eff_val_len)) {
+
+		/*
+		 * get the effective length of the name in case it's not a valid string
+		 * don't do this on the value because it can be binary data
+		 */
+		if (!fcgi_param_get_eff_len(p, p+name_len, &eff_name_len)){
 			/* Malicious request */
 			ret = 0;
 			break;
@@ -473,7 +477,7 @@ static int fcgi_get_params(fcgi_request
 		}
 		memcpy(tmp, p, eff_name_len);
 		tmp[eff_name_len] = 0;
-		s = estrndup((char*)p + name_len, eff_val_len);
+		s = estrndup((char*)p + name_len, val_len);
 		if (s == NULL) {
 			ret = 0;
 			break;
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm.c php-5.4.5/sapi/fpm/fpm/fpm.c
--- php-5.4.4/sapi/fpm/fpm/fpm.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm.c	2012-07-18 08:19:16.000000000 +0200
@@ -37,10 +37,12 @@ struct fpm_globals_s fpm_globals = {
 	.max_requests = 0,
 	.is_child = 0,
 	.test_successful = 0,
-	.heartbeat = 0
+	.heartbeat = 0,
+	.run_as_root = 0,
+	.send_config_signal = 0,
 };
 
-int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf) /* {{{ */
+int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root) /* {{{ */
 {
 	fpm_globals.argc = argc;
 	fpm_globals.argv = argv;
@@ -49,6 +51,7 @@ int fpm_init(int argc, char **argv, char
 	}
 	fpm_globals.prefix = prefix;
 	fpm_globals.pid = pid;
+	fpm_globals.run_as_root = run_as_root;
 
 	if (0 > fpm_php_init_main()           ||
 	    0 > fpm_stdio_init_main()         ||
@@ -64,7 +67,7 @@ int fpm_init(int argc, char **argv, char
 	    0 > fpm_event_init_main()) {
 
 		if (fpm_globals.test_successful) {
-			exit(0);
+			exit(FPM_EXIT_OK);
 		} else {
 			zlog(ZLOG_ERROR, "FPM initialization failed");
 			return -1;
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_children.c php-5.4.5/sapi/fpm/fpm/fpm_children.c
--- php-5.4.4/sapi/fpm/fpm/fpm_children.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_children.c	2012-07-18 08:19:16.000000000 +0200
@@ -156,7 +156,7 @@ static void fpm_child_init(struct fpm_wo
 	    0 > fpm_php_init_child(wp)) {
 
 		zlog(ZLOG_ERROR, "[pool %s] child failed to initialize", wp->config->name);
-		exit(255);
+		exit(FPM_EXIT_SOFTWARE);
 	}
 }
 /* }}} */
@@ -198,7 +198,7 @@ void fpm_children_bury() /* {{{ */
 				restart_child = 0;
 			}
 
-			if (WEXITSTATUS(status) != 0) {
+			if (WEXITSTATUS(status) != FPM_EXIT_OK) {
 				severity = ZLOG_WARNING;
 			}
 
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_conf.c php-5.4.5/sapi/fpm/fpm/fpm_conf.c
--- php-5.4.4/sapi/fpm/fpm/fpm_conf.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_conf.c	2012-07-18 08:19:16.000000000 +0200
@@ -53,7 +53,9 @@
 
 static int fpm_conf_load_ini_file(char *filename TSRMLS_DC);
 static char *fpm_conf_set_integer(zval *value, void **config, intptr_t offset);
+#if 0 /* not used for now */
 static char *fpm_conf_set_long(zval *value, void **config, intptr_t offset);
+#endif
 static char *fpm_conf_set_time(zval *value, void **config, intptr_t offset);
 static char *fpm_conf_set_boolean(zval *value, void **config, intptr_t offset);
 static char *fpm_conf_set_string(zval *value, void **config, intptr_t offset);
@@ -70,6 +72,7 @@ struct fpm_global_config_s fpm_global_co
 	.syslog_facility = -1,
 #endif
 	.process_max = 0,
+	.process_priority = 64, /* 64 means unset */
 };
 static struct fpm_worker_pool_s *current_wp = NULL;
 static int ini_recursion = 0;
@@ -92,6 +95,7 @@ static struct ini_value_parser_s ini_fpm
 	{ "emergency_restart_interval",  &fpm_conf_set_time,            GO(emergency_restart_interval) },
 	{ "process_control_timeout",     &fpm_conf_set_time,            GO(process_control_timeout) },
 	{ "process.max",                 &fpm_conf_set_integer,         GO(process_max) },
+	{ "process.priority",            &fpm_conf_set_integer,         GO(process_priority) },
 	{ "daemonize",                   &fpm_conf_set_boolean,         GO(daemonize) },
 	{ "rlimit_files",                &fpm_conf_set_integer,         GO(rlimit_files) },
 	{ "rlimit_core",                 &fpm_conf_set_rlimit_core,     GO(rlimit_core) },
@@ -112,6 +116,7 @@ static struct ini_value_parser_s ini_fpm
 	{ "listen.group",              &fpm_conf_set_string,      WPO(listen_group) },
 	{ "listen.mode",               &fpm_conf_set_string,      WPO(listen_mode) },
 	{ "listen.allowed_clients",    &fpm_conf_set_string,      WPO(listen_allowed_clients) },
+	{ "process.priority",          &fpm_conf_set_integer,     WPO(process_priority) },
 	{ "pm",                        &fpm_conf_set_pm,          WPO(pm) },
 	{ "pm.max_children",           &fpm_conf_set_integer,     WPO(pm_max_children) },
 	{ "pm.start_servers",          &fpm_conf_set_integer,     WPO(pm_start_servers) },
@@ -239,6 +244,7 @@ static char *fpm_conf_set_integer(zval *
 }
 /* }}} */
 
+#if 0 /* not used for now */
 static char *fpm_conf_set_long(zval *value, void **config, intptr_t offset) /* {{{ */
 {
 	char *val = Z_STRVAL_P(value);
@@ -254,6 +260,7 @@ static char *fpm_conf_set_long(zval *val
 	return NULL;
 }
 /* }}} */
+#endif
 
 static char *fpm_conf_set_time(zval *value, void **config, intptr_t offset) /* {{{ */
 {
@@ -577,6 +584,7 @@ static void *fpm_worker_pool_config_allo
 	memset(wp->config, 0, sizeof(struct fpm_worker_pool_config_s));
 	wp->config->listen_backlog = FPM_BACKLOG_DEFAULT;
 	wp->config->pm_process_idle_timeout = 10; /* 10s by default */
+	wp->config->process_priority = 64; /* 64 means unset */
 
 	if (!fpm_worker_all_pools) {
 		fpm_worker_all_pools = wp;
@@ -704,7 +712,7 @@ static int fpm_evaluate_full_path(char *
 
 static int fpm_conf_process_all_pools() /* {{{ */
 {
-	struct fpm_worker_pool_s *wp;
+	struct fpm_worker_pool_s *wp, *wp2;
 
 	if (!fpm_worker_all_pools) {
 		zlog(ZLOG_ERROR, "No pool defined. at least one pool section must be specified in config file");
@@ -723,8 +731,8 @@ static int fpm_conf_process_all_pools()
 			}
 		}
 
-		/* user */
-		if (!wp->config->user) {
+		/* alert if user is not set only if we are not root*/
+		if (!wp->config->user && !geteuid()) {
 			zlog(ZLOG_ALERT, "[pool %s] user has not been defined", wp->config->name);
 			return -1;
 		}
@@ -741,6 +749,11 @@ static int fpm_conf_process_all_pools()
 			return -1;
 		}
 
+		if (wp->config->process_priority != 64 && (wp->config->process_priority < -19 || wp->config->process_priority > 20)) {
+			zlog(ZLOG_ERROR, "[pool %s] process.priority must be included into [-19,20]", wp->config->name);
+			return -1;
+		}
+
 		/* pm */
 		if (wp->config->pm != PM_STYLE_STATIC && wp->config->pm != PM_STYLE_DYNAMIC && wp->config->pm != PM_STYLE_ONDEMAND) {
 			zlog(ZLOG_ALERT, "[pool %s] the process manager is missing (static, dynamic or ondemand)", wp->config->name);
@@ -1044,6 +1057,20 @@ static int fpm_conf_process_all_pools()
 			}
 		}
 	}
+
+	/* ensure 2 pools do not use the same listening address */
+	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
+		for (wp2 = fpm_worker_all_pools; wp2; wp2 = wp2->next) {
+			if (wp == wp2) {
+				continue;
+			}
+
+			if (wp->config->listen_address && *wp->config->listen_address && wp2->config->listen_address && *wp2->config->listen_address && !strcmp(wp->config->listen_address, wp2->config->listen_address)) {
+				zlog(ZLOG_ERROR, "[pool %s] unable to set listen address as it's already used in another pool '%s'", wp2->config->name, wp->config->name);
+				return -1;
+			}
+		}
+	}
 	return 0;
 }
 /* }}} */
@@ -1103,6 +1130,11 @@ static int fpm_conf_post_process(TSRMLS_
 		return -1;
 	}
 
+	if (fpm_global_config.process_priority != 64 && (fpm_global_config.process_priority < -19 || fpm_global_config.process_priority > 20)) {
+		zlog(ZLOG_ERROR, "process.priority must be included into [-19,20]");
+		return -1;
+	}
+
 	if (!fpm_global_config.error_log) {
 		fpm_global_config.error_log = strdup("log/php-fpm.log");
 	}
@@ -1485,6 +1517,11 @@ static void fpm_conf_dump() /* {{{ */
 	zlog(ZLOG_NOTICE, "\temergency_restart_threshold = %d", fpm_global_config.emergency_restart_threshold);
 	zlog(ZLOG_NOTICE, "\tprocess_control_timeout = %ds",    fpm_global_config.process_control_timeout);
 	zlog(ZLOG_NOTICE, "\tprocess.max = %d",                 fpm_global_config.process_max);
+	if (fpm_global_config.process_priority == 64) {
+		zlog(ZLOG_NOTICE, "\tprocess.priority = undefined");
+	} else {
+		zlog(ZLOG_NOTICE, "\tprocess.priority = %d", fpm_global_config.process_priority);
+	}
 	zlog(ZLOG_NOTICE, "\tdaemonize = %s",                   BOOL2STR(fpm_global_config.daemonize));
 	zlog(ZLOG_NOTICE, "\trlimit_files = %d",                fpm_global_config.rlimit_files);
 	zlog(ZLOG_NOTICE, "\trlimit_core = %d",                 fpm_global_config.rlimit_core);
@@ -1504,6 +1541,11 @@ static void fpm_conf_dump() /* {{{ */
 		zlog(ZLOG_NOTICE, "\tlisten.group = %s",               STR2STR(wp->config->listen_group));
 		zlog(ZLOG_NOTICE, "\tlisten.mode = %s",                STR2STR(wp->config->listen_mode));
 		zlog(ZLOG_NOTICE, "\tlisten.allowed_clients = %s",     STR2STR(wp->config->listen_allowed_clients));
+		if (wp->config->process_priority == 64) {
+			zlog(ZLOG_NOTICE, "\tprocess.priority = undefined");
+		} else {
+			zlog(ZLOG_NOTICE, "\tprocess.priority = %d", wp->config->process_priority);
+		}
 		zlog(ZLOG_NOTICE, "\tpm = %s",                         PM2STR(wp->config->pm));
 		zlog(ZLOG_NOTICE, "\tpm.max_children = %d",            wp->config->pm_max_children);
 		zlog(ZLOG_NOTICE, "\tpm.start_servers = %d",           wp->config->pm_start_servers);
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_conf.h php-5.4.5/sapi/fpm/fpm/fpm_conf.h
--- php-5.4.4/sapi/fpm/fpm/fpm_conf.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_conf.h	2012-07-18 08:19:16.000000000 +0200
@@ -35,6 +35,7 @@ struct fpm_global_config_s {
 	int emergency_restart_interval;
 	int process_control_timeout;
 	int process_max;
+	int process_priority;
 	int daemonize;
 	int rlimit_files;
 	int rlimit_core;
@@ -57,6 +58,7 @@ struct fpm_worker_pool_config_s {
 	char *listen_group;
 	char *listen_mode;
 	char *listen_allowed_clients;
+	int process_priority;
 	int pm;
 	int pm_max_children;
 	int pm_start_servers;
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm.h php-5.4.5/sapi/fpm/fpm/fpm.h
--- php-5.4.4/sapi/fpm/fpm/fpm.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm.h	2012-07-18 08:19:16.000000000 +0200
@@ -7,8 +7,37 @@
 
 #include <unistd.h>
 
+#ifdef HAVE_SYSEXITS_H
+#include <sysexits.h>
+#endif
+
+#ifdef EX_OK
+#define FPM_EXIT_OK EX_OK
+#else
+#define FPM_EXIT_OK 0
+#endif
+
+#ifdef EX_USAGE
+#define FPM_EXIT_USAGE EX_USAGE
+#else
+#define FPM_EXIT_USAGE 64
+#endif
+
+#ifdef EX_SOFTWARE
+#define FPM_EXIT_SOFTWARE EX_SOFTWARE
+#else
+#define FPM_EXIT_SOFTWARE 70
+#endif
+
+#ifdef EX_CONFIG
+#define FPM_EXIT_CONFIG EX_CONFIG
+#else
+#define FPM_EXIT_CONFIG 78
+#endif
+
+
 int fpm_run(int *max_requests);
-int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf);
+int fpm_init(int argc, char **argv, char *config, char *prefix, char *pid, int test_conf, int run_as_root);
 
 struct fpm_globals_s {
 	pid_t parent_pid;
@@ -25,6 +54,8 @@ struct fpm_globals_s {
 	int is_child;
 	int test_successful;
 	int heartbeat;
+	int run_as_root;
+	int send_config_signal;
 };
 
 extern struct fpm_globals_s fpm_globals;
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_main.c php-5.4.5/sapi/fpm/fpm/fpm_main.c
--- php-5.4.4/sapi/fpm/fpm/fpm_main.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_main.c	2012-07-18 08:19:16.000000000 +0200
@@ -154,6 +154,7 @@ static const opt_struct OPTIONS[] = {
 	{'t', 0, "test"},
 	{'p', 1, "prefix"},
 	{'g', 1, "pid"},
+	{'R', 0, "allow-to-run-as-root"},
 	{'-', 0, NULL} /* end of args */
 };
 
@@ -646,12 +647,38 @@ static void sapi_cgi_register_variables(
 	}
 }
 
-static void sapi_cgi_log_message(char *message TSRMLS_DC)
+/* {{{ sapi_cgi_log_fastcgi
+ *
+ * Ignore level, we want to send all messages through fastcgi
+ */
+void sapi_cgi_log_fastcgi(int level, char *message, size_t len)
 {
-	if (CGIG(fcgi_logging)) {
-		zlog(ZLOG_NOTICE, "PHP message: %s", message);
+	TSRMLS_FETCH();
+
+	fcgi_request *request = (fcgi_request*) SG(server_context);
+
+	/* ensure we want:
+	 * - to log (fastcgi.logging in php.ini)
+	 * - we are currently dealing with a request
+	 * - the message is not empty
+	 */
+	if (CGIG(fcgi_logging) && request && message && len > 0) {
+		char *buf = malloc(len + 2);
+		memcpy(buf, message, len);
+		memcpy(buf + len, "\n", sizeof("\n"));
+		fcgi_write(request, FCGI_STDERR, buf, len+1);
+		free(buf);
+	}
 	}
+/* }}} */
+
+/* {{{ sapi_cgi_log_message
+ */
+static void sapi_cgi_log_message(char *message)
+{
+	zlog(ZLOG_NOTICE, "PHP message: %s", message);
 }
+/* }}} */
 
 /* {{{ php_cgi_ini_activate_user_config
  */
@@ -900,7 +927,9 @@ static void php_cgi_usage(char *argv0)
 				"                   Specify the PID file location.\n"
 				"  -y, --fpm-config <file>\n"
 				"                   Specify alternative path to FastCGI process manager config file.\n"
-				"  -t, --test       Test FPM configuration and exit\n",
+				"  -t, --test       Test FPM configuration and exit\n"
+				"  -R, --allow-to-run-as-root\n"
+				"                   Allow pool to run as root (disabled by default)\n",
 				prog, PHP_PREFIX);
 }
 /* }}} */
@@ -1499,7 +1528,7 @@ static zend_module_entry cgi_module_entr
  */
 int main(int argc, char *argv[])
 {
-	int exit_status = SUCCESS;
+	int exit_status = FPM_EXIT_OK;
 	int cgi = 0, c, use_extended_info = 0;
 	zend_file_handle file_handle;
 
@@ -1522,6 +1551,7 @@ int main(int argc, char *argv[])
 	char *fpm_pid = NULL;
 	int test_conf = 0;
 	int php_information = 0;
+	int php_allow_to_run_as_root = 0;
 
 #ifdef HAVE_SIGNAL_H
 #if defined(SIGPIPE) && defined(SIG_IGN)
@@ -1629,13 +1659,17 @@ int main(int argc, char *argv[])
 				php_output_end_all(TSRMLS_C);
 				php_output_deactivate(TSRMLS_C);
 				fcgi_shutdown();
-				exit_status = 0;
+				exit_status = FPM_EXIT_OK;
 				goto out;
 
 			case 'i': /* php info & quit */
 				php_information = 1;
 				break;
 
+			case 'R': /* allow to run as root */
+				php_allow_to_run_as_root = 1;
+				break;
+
 			default:
 			case 'h':
 			case '?':
@@ -1646,7 +1680,7 @@ int main(int argc, char *argv[])
 				php_output_end_all(TSRMLS_C);
 				php_output_deactivate(TSRMLS_C);
 				fcgi_shutdown();
-				exit_status = 0;
+				exit_status = (c == 'h') ? FPM_EXIT_OK : FPM_EXIT_USAGE;
 				goto out;
 
 			case 'v': /* show php version & quit */
@@ -1654,7 +1688,7 @@ int main(int argc, char *argv[])
 				if (php_request_startup(TSRMLS_C) == FAILURE) {
 					SG(server_context) = NULL;
 					php_module_shutdown(TSRMLS_C);
-					return FAILURE;
+					return FPM_EXIT_SOFTWARE;
 				}
 				SG(headers_sent) = 1;
 				SG(request_info).no_headers = 1;
@@ -1666,7 +1700,7 @@ int main(int argc, char *argv[])
 #endif
 				php_request_shutdown((void *) 0);
 				fcgi_shutdown();
-				exit_status = 0;
+				exit_status = FPM_EXIT_OK;
 				goto out;
 		}
 	}
@@ -1677,14 +1711,14 @@ int main(int argc, char *argv[])
 		if (php_request_startup(TSRMLS_C) == FAILURE) {
 			SG(server_context) = NULL;
 			php_module_shutdown(TSRMLS_C);
-			return FAILURE;
+			return FPM_EXIT_SOFTWARE;
 		}
 		SG(headers_sent) = 1;
 		SG(request_info).no_headers = 1;
 		php_print_info(0xFFFFFFFF TSRMLS_CC);
 		php_request_shutdown((void *) 0);
 		fcgi_shutdown();
-		exit_status = 0;
+		exit_status = FPM_EXIT_OK;
 		goto out;
 	}
 
@@ -1697,7 +1731,7 @@ int main(int argc, char *argv[])
 		php_output_end_all(TSRMLS_C);
 		php_output_deactivate(TSRMLS_C);
 		fcgi_shutdown();
-		exit_status = 0;
+		exit_status = FPM_EXIT_USAGE;
 		goto out;
 	}
 
@@ -1716,7 +1750,7 @@ int main(int argc, char *argv[])
 #ifdef ZTS
 		tsrm_shutdown();
 #endif
-		return FAILURE;
+		return FPM_EXIT_SOFTWARE;
 	}
 	
 	if (use_extended_info) {
@@ -1759,19 +1793,31 @@ consult the installation file that came
 			 */
 			tsrm_shutdown();
 #endif
-			return FAILURE;
+			return FPM_EXIT_SOFTWARE;
 		}
 	}
 
-	if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf)) {
-		return FAILURE;
+	if (0 > fpm_init(argc, argv, fpm_config ? fpm_config : CGIG(fpm_config), fpm_prefix, fpm_pid, test_conf, php_allow_to_run_as_root)) {
+
+		if (fpm_globals.send_config_signal) {
+			zlog(ZLOG_DEBUG, "Sending SIGUSR2 (error) to parent %d", getppid());
+			kill(getppid(), SIGUSR2);
+		}
+		return FPM_EXIT_CONFIG;
 	}
 
+	if (fpm_globals.send_config_signal) {
+		zlog(ZLOG_DEBUG, "Sending SIGUSR1 (OK) to parent %d", getppid());
+		kill(getppid(), SIGUSR1);
+	}
 	fpm_is_running = 1;
 
 	fcgi_fd = fpm_run(&max_requests);
 	parent = 0;
 
+	/* onced forked tell zlog to also send messages through sapi_cgi_log_fastcgi() */
+	zlog_set_external_logger(sapi_cgi_log_fastcgi);
+
 	/* make php call us to get _ENV vars */
 	php_php_import_environment_variables = php_import_environment_variables;
 	php_import_environment_variables = cgi_php_import_environment_variables;
@@ -1795,7 +1841,7 @@ consult the installation file that came
 				fcgi_finish_request(&request, 1);
 				SG(server_context) = NULL;
 				php_module_shutdown(TSRMLS_C);
-				return FAILURE;
+				return FPM_EXIT_SOFTWARE;
 			}
 
 			/* check if request_method has been sent.
@@ -1883,17 +1929,9 @@ fastcgi_request_done:
 
 			php_request_shutdown((void *) 0);
 
-			if (exit_status == 0) {
-				exit_status = EG(exit_status);
-			}
-
 			requests++;
 			if (max_requests && (requests == max_requests)) {
 				fcgi_finish_request(&request, 1);
-				if (max_requests != 1) {
-					/* no need to return exit_status of the last request */
-					exit_status = 0;
-				}
 				break;
 			}
 			/* end of fastcgi loop */
@@ -1907,7 +1945,7 @@ fastcgi_request_done:
 			free(cgi_sapi_module.ini_entries);
 		}
 	} zend_catch {
-		exit_status = 255;
+		exit_status = FPM_EXIT_SOFTWARE;
 	} zend_end_try();
 
 out:
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_php.c php-5.4.5/sapi/fpm/fpm/fpm_php.c
--- php-5.4.4/sapi/fpm/fpm/fpm_php.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_php.c	2012-07-18 08:19:16.000000000 +0200
@@ -257,3 +257,41 @@ int fpm_php_limit_extensions(char *path)
 	return 1; /* extension not found: not allowed  */
 }
 /* }}} */
+
+char* fpm_php_get_string_from_table(char *table, char *key TSRMLS_DC) /* {{{ */
+{
+	zval **data, **tmp;
+	char *string_key;
+	uint string_len;
+	ulong num_key;
+	if (!table || !key) {
+		return NULL;
+	}
+
+	/* inspired from ext/standard/info.c */
+
+	zend_is_auto_global(table, strlen(table) TSRMLS_CC);
+
+	/* find the table and ensure it's an array */
+	if (zend_hash_find(&EG(symbol_table), table, strlen(table) + 1, (void **) &data) == SUCCESS && Z_TYPE_PP(data) == IS_ARRAY) {
+
+		/* reset the internal pointer */
+		zend_hash_internal_pointer_reset(Z_ARRVAL_PP(data));
+
+		/* parse the array to look for our key */
+		while (zend_hash_get_current_data(Z_ARRVAL_PP(data), (void **) &tmp) == SUCCESS) {
+			/* ensure the key is a string */
+			if (zend_hash_get_current_key_ex(Z_ARRVAL_PP(data), &string_key, &string_len, &num_key, 0, NULL) == HASH_KEY_IS_STRING) {
+				/* compare to our key */
+				if (!strncmp(string_key, key, string_len)) {
+					return Z_STRVAL_PP(tmp);
+				}
+			}
+			zend_hash_move_forward(Z_ARRVAL_PP(data));
+		}
+	}
+
+	return NULL;
+}
+/* }}} */
+
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_php.h php-5.4.5/sapi/fpm/fpm/fpm_php.h
--- php-5.4.4/sapi/fpm/fpm/fpm_php.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_php.h	2012-07-18 08:19:16.000000000 +0200
@@ -44,6 +44,7 @@ void fpm_php_soft_quit();
 int fpm_php_init_main();
 int fpm_php_apply_defines_ex(struct key_value_s *kv, int mode);
 int fpm_php_limit_extensions(char *path);
+char* fpm_php_get_string_from_table(char *table, char *key TSRMLS_DC);
 
 #endif
 
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_process_ctl.c php-5.4.5/sapi/fpm/fpm/fpm_process_ctl.c
--- php-5.4.4/sapi/fpm/fpm/fpm_process_ctl.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_process_ctl.c	2012-07-18 08:19:16.000000000 +0200
@@ -71,7 +71,7 @@ static void fpm_pctl_exit() /* {{{ */
 
 	fpm_conf_unlink_pid();
 	fpm_cleanups_run(FPM_CLEANUP_PARENT_EXIT_MAIN);
-	exit(0);
+	exit(FPM_EXIT_OK);
 }
 /* }}} */
 
@@ -100,7 +100,7 @@ static void fpm_pctl_exec() /* {{{ */
 	fpm_cleanups_run(FPM_CLEANUP_PARENT_EXEC);
 	execvp(saved_argv[0], saved_argv);
 	zlog(ZLOG_SYSERROR, "failed to reload: execvp() failed");
-	exit(1);
+	exit(FPM_EXIT_SOFTWARE);
 }
 /* }}} */
 
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_signals.c php-5.4.5/sapi/fpm/fpm/fpm_signals.c
--- php-5.4.4/sapi/fpm/fpm/fpm_signals.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_signals.c	2012-07-18 08:19:16.000000000 +0200
@@ -249,3 +249,15 @@ int fpm_signals_get_fd() /* {{{ */
 }
 /* }}} */
 
+void fpm_signals_sighandler_exit_ok(pid_t pid) /* {{{ */
+{
+	exit(FPM_EXIT_OK);
+}
+/* }}} */
+
+void fpm_signals_sighandler_exit_config(pid_t pid) /* {{{ */
+{
+	exit(FPM_EXIT_CONFIG);
+}
+/* }}} */
+
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_signals.h php-5.4.5/sapi/fpm/fpm/fpm_signals.h
--- php-5.4.4/sapi/fpm/fpm/fpm_signals.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_signals.h	2012-07-18 08:19:16.000000000 +0200
@@ -11,6 +11,9 @@ int fpm_signals_init_main();
 int fpm_signals_init_child();
 int fpm_signals_get_fd();
 
+void fpm_signals_sighandler_exit_ok(pid_t pid);
+void fpm_signals_sighandler_exit_config(pid_t pid);
+
 extern const char *fpm_signal_names[NSIG + 1];
 
 #endif
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_sockets.c php-5.4.5/sapi/fpm/fpm/fpm_sockets.c
--- php-5.4.4/sapi/fpm/fpm/fpm_sockets.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_sockets.c	2012-07-18 08:19:16.000000000 +0200
@@ -179,6 +179,10 @@ static int fpm_sockets_new_listening_soc
 	setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
 
 	if (wp->listen_address_domain == FPM_AF_UNIX) {
+		if (fpm_socket_unix_test_connect((struct sockaddr_un *)sa, socklen) == 0) {
+			zlog(ZLOG_ERROR, "An another FPM instance seems to already listen on %s", ((struct sockaddr_un *) sa)->sun_path);
+			return -1;
+		}
 		unlink( ((struct sockaddr_un *) sa)->sun_path);
 		saved_umask = umask(0777 ^ wp->socket_mode);
 	}
@@ -450,3 +454,24 @@ int fpm_socket_get_listening_queue(int s
 }
 
 #endif
+
+int fpm_socket_unix_test_connect(struct sockaddr_un *sun, size_t socklen) /* {{{ */
+{
+	int fd;
+
+	if (!sun || sun->sun_family != AF_UNIX) {
+		return -1;
+	}
+
+	if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+		return -1;
+	}
+
+	if (connect(fd, (struct sockaddr *)sun, socklen) == -1) {
+		return -1;
+	}
+
+	close(fd);
+	return 0;
+}
+/* }}} */
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_sockets.h php-5.4.5/sapi/fpm/fpm/fpm_sockets.h
--- php-5.4.4/sapi/fpm/fpm/fpm_sockets.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_sockets.h	2012-07-18 08:19:16.000000000 +0200
@@ -5,6 +5,9 @@
 #ifndef FPM_MISC_H
 #define FPM_MISC_H 1
 
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -22,6 +25,7 @@
 enum fpm_address_domain fpm_sockets_domain_from_address(char *addr);
 int fpm_sockets_init_main();
 int fpm_socket_get_listening_queue(int sock, unsigned *cur_lq, unsigned *max_lq);
+int fpm_socket_unix_test_connect(struct sockaddr_un *sun, size_t socklen);
 
 
 static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_status.c php-5.4.5/sapi/fpm/fpm/fpm_status.c
--- php-5.4.4/sapi/fpm/fpm/fpm_status.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_status.c	2012-07-18 08:19:16.000000000 +0200
@@ -14,6 +14,7 @@
 #include "zlog.h"
 #include "fpm_atomic.h"
 #include "fpm_conf.h"
+#include "fpm_php.h"
 #include <ext/standard/html.h>
 
 static char *fpm_status_uri = NULL;
@@ -125,13 +126,13 @@ int fpm_status_handle_request(TSRMLS_D)
 		}
 
 		/* full status ? */
-		full = SG(request_info).request_uri && strstr(SG(request_info).query_string, "full");
+		full = (fpm_php_get_string_from_table("_GET", "full" TSRMLS_CC) != NULL);
 		short_syntax = short_post = NULL;
 		full_separator = full_pre = full_syntax = full_post = NULL;
 		encode = 0;
 
 		/* HTML */
-		if (SG(request_info).query_string && strstr(SG(request_info).query_string, "html")) {
+		if (fpm_php_get_string_from_table("_GET", "html" TSRMLS_CC)) {
 			sapi_add_header_ex(ZEND_STRL("Content-Type: text/html"), 1, 1 TSRMLS_CC);
 			time_format = "%d/%b/%Y:%H:%M:%S %z";
 			encode = 1;
@@ -205,7 +206,7 @@ int fpm_status_handle_request(TSRMLS_D)
 			}
 
 		/* XML */
-		} else if (SG(request_info).request_uri && strstr(SG(request_info).query_string, "xml")) {
+		} else if (fpm_php_get_string_from_table("_GET", "xml" TSRMLS_CC)) {
 			sapi_add_header_ex(ZEND_STRL("Content-Type: text/xml"), 1, 1 TSRMLS_CC);
 			time_format = "%s";
 			encode = 1;
@@ -256,7 +257,7 @@ int fpm_status_handle_request(TSRMLS_D)
 				}
 
 			/* JSON */
-		} else if (SG(request_info).request_uri && strstr(SG(request_info).query_string, "json")) {
+		} else if (fpm_php_get_string_from_table("_GET", "json" TSRMLS_CC)) {
 			sapi_add_header_ex(ZEND_STRL("Content-Type: application/json"), 1, 1 TSRMLS_CC);
 			time_format = "%s";
 
diff -urNapw php-5.4.4/sapi/fpm/fpm/fpm_unix.c php-5.4.5/sapi/fpm/fpm/fpm_unix.c
--- php-5.4.4/sapi/fpm/fpm/fpm_unix.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/fpm_unix.c	2012-07-18 08:19:16.000000000 +0200
@@ -23,6 +23,7 @@
 #include "fpm_clock.h"
 #include "fpm_stdio.h"
 #include "fpm_unix.h"
+#include "fpm_signals.h"
 #include "zlog.h"
 
 size_t fpm_pagesize;
@@ -112,12 +113,12 @@ static int fpm_unix_conf_wp(struct fpm_w
 			}
 		}
 
-#ifndef I_REALLY_WANT_ROOT_PHP
+		if (!fpm_globals.run_as_root) {
 		if (wp->set_uid == 0 || wp->set_gid == 0) {
 			zlog(ZLOG_ERROR, "[pool %s] please specify user and group other than root", wp->config->name);
 			return -1;
 		}
-#endif
+		}
 	} else { /* not root */
 		if (wp->config->user && *wp->config->user) {
 			zlog(ZLOG_WARNING, "[pool %s] 'user' directive is ignored when FPM is not running as root", wp->config->name);
@@ -128,6 +129,9 @@ static int fpm_unix_conf_wp(struct fpm_w
 		if (wp->config->chroot && *wp->config->chroot) {
 			zlog(ZLOG_WARNING, "[pool %s] 'chroot' directive is ignored when FPM is not running as root", wp->config->name);
 		}
+		if (wp->config->process_priority != 64) {
+			zlog(ZLOG_WARNING, "[pool %s] 'process.priority' directive is ignored when FPM is not running as root", wp->config->name);
+		}
 
 		/* set up HOME and USER anyway */
 		pwd = getpwuid(getuid());
@@ -183,6 +187,14 @@ int fpm_unix_init_child(struct fpm_worke
 	}
 
 	if (is_root) {
+
+		if (wp->config->process_priority != 64) {
+			if (setpriority(PRIO_PROCESS, 0, wp->config->process_priority) < 0) {
+				zlog(ZLOG_SYSERROR, "[pool %s] Unable to set priority for this new process", wp->config->name);
+				return -1;
+			}
+		}
+
 		if (wp->set_gid) {
 			if (0 > setgid(wp->set_gid)) {
 				zlog(ZLOG_SYSERROR, "[pool %s] failed to setgid(%d)", wp->config->name, wp->set_gid);
@@ -217,6 +229,7 @@ int fpm_unix_init_child(struct fpm_worke
 int fpm_unix_init_main() /* {{{ */
 {
 	struct fpm_worker_pool_s *wp;
+	int is_root = !geteuid();
 
 	if (fpm_global_config.rlimit_files) {
 		struct rlimit r;
@@ -242,23 +255,92 @@ int fpm_unix_init_main() /* {{{ */
 
 	fpm_pagesize = getpagesize();
 	if (fpm_global_config.daemonize) {
-		switch (fork()) {
-			case -1 :
+		/*
+		 * If daemonize, the calling process will die soon
+		 * and the master process continues to initialize itself.
+		 *
+		 * The parent process has then to wait for the master
+		 * process to initialize to return a consistent exit
+		 * value. For this pupose, the master process will
+		 * send USR1 if everything went well and USR2
+		 * otherwise.
+		 */
+
+		struct sigaction act;
+		struct sigaction oldact_usr1;
+		struct sigaction oldact_usr2;
+		struct timeval tv;
+
+		/*
+		 * set sigaction for USR1 before fork
+		 * save old sigaction to restore it after
+		 * fork in the child process (the master process)
+		 */
+		memset(&act, 0, sizeof(act));
+		memset(&act, 0, sizeof(oldact_usr1));
+		act.sa_handler = fpm_signals_sighandler_exit_ok;
+		sigfillset(&act.sa_mask);
+		sigaction(SIGUSR1, &act, &oldact_usr1);
+
+		/*
+		 * set sigaction for USR2 before fork
+		 * save old sigaction to restore it after
+		 * fork in the child process (the master process)
+		 */
+		memset(&act, 0, sizeof(act));
+		memset(&act, 0, sizeof(oldact_usr2));
+		act.sa_handler = fpm_signals_sighandler_exit_config;
+		sigfillset(&act.sa_mask);
+		sigaction(SIGUSR2, &act, &oldact_usr2);
+
+		/* then fork */
+		pid_t pid = fork();
+		switch (pid) {
+
+			case -1 : /* error */
 				zlog(ZLOG_SYSERROR, "failed to daemonize");
 				return -1;
-			case 0 :
+
+			case 0 : /* children */
+				/* restore USR1 and USR2 sigaction */
+				sigaction(SIGUSR1, &oldact_usr1, NULL);
+				sigaction(SIGUSR2, &oldact_usr2, NULL);
+				fpm_globals.send_config_signal = 1;
 				break;
-			default :
+
+			default : /* parent */
 				fpm_cleanups_run(FPM_CLEANUP_PARENT_EXIT);
-				exit(0);
+
+				/*
+				 * wait for 10s before exiting with error
+				 * the child is supposed to send USR1 or USR2 to tell the parent
+				 * how it goes for it
+				 */
+				tv.tv_sec = 10;
+				tv.tv_usec = 0;
+				zlog(ZLOG_DEBUG, "The calling process is waiting for the master process to ping");
+				select(0, NULL, NULL, NULL, &tv);
+				exit(FPM_EXIT_SOFTWARE);
 		}
 	}
 
+	/* continue as a child */
 	setsid();
 	if (0 > fpm_clock_init()) {
 		return -1;
 	}
 
+	if (fpm_global_config.process_priority != 64) {
+		if (is_root) {
+			if (setpriority(PRIO_PROCESS, 0, fpm_global_config.process_priority) < 0) {
+				zlog(ZLOG_SYSERROR, "Unable to set priority for the master process");
+				return -1;
+			}
+		} else {
+			zlog(ZLOG_WARNING, "'process.priority' directive is ignored when FPM is not running as root");
+		}
+	}
+
 	fpm_globals.parent_pid = getpid();
 	for (wp = fpm_worker_all_pools; wp; wp = wp->next) {
 		if (0 > fpm_unix_conf_wp(wp)) {
diff -urNapw php-5.4.4/sapi/fpm/fpm/zlog.c php-5.4.5/sapi/fpm/fpm/zlog.c
--- php-5.4.4/sapi/fpm/fpm/zlog.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/zlog.c	2012-07-18 08:19:16.000000000 +0200
@@ -22,6 +22,7 @@
 static int zlog_fd = -1;
 static int zlog_level = ZLOG_NOTICE;
 static int launched = 0;
+static void (*external_logger)(int, char *, size_t) = NULL;
 
 static const char *level_names[] = {
 	[ZLOG_DEBUG]   = "DEBUG",
@@ -41,6 +42,12 @@ const int syslog_priorities[] = {
 };
 #endif
 
+void zlog_set_external_logger(void (*logger)(int, char *, size_t)) /* {{{ */
+{
+	external_logger = logger;
+}
+/* }}} */
+
 const char *zlog_get_level_name(int log_level) /* {{{ */
 {
 	if (log_level < 0) {
@@ -101,6 +108,19 @@ void zlog_ex(const char *function, int l
 	int truncated = 0;
 	int saved_errno;
 
+	if (external_logger) {
+		va_start(args, fmt);
+		len = vsnprintf(buf, buf_size, fmt, args);
+		va_end(args);
+		if (len >= buf_size) {
+			memcpy(buf + buf_size - sizeof("..."), "...", sizeof("...") - 1);
+			len = buf_size - 1;
+		}
+		external_logger(flags & ZLOG_LEVEL_MASK, buf, len);
+		len = 0;
+		memset(buf, '\0', buf_size);
+	}
+
 	if ((flags & ZLOG_LEVEL_MASK) < zlog_level) {
 		return;
 	}
diff -urNapw php-5.4.4/sapi/fpm/fpm/zlog.h php-5.4.5/sapi/fpm/fpm/zlog.h
--- php-5.4.4/sapi/fpm/fpm/zlog.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/fpm/zlog.h	2012-07-18 08:19:16.000000000 +0200
@@ -9,6 +9,7 @@
 
 struct timeval;
 
+void zlog_set_external_logger(void (*logger)(int, char *, size_t));
 int zlog_set_fd(int new_fd);
 int zlog_set_level(int new_value);
 const char *zlog_get_level_name(int log_level);
diff -urNapw php-5.4.4/sapi/fpm/php-fpm.conf.in php-5.4.5/sapi/fpm/php-fpm.conf.in
--- php-5.4.4/sapi/fpm/php-fpm.conf.in	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/sapi/fpm/php-fpm.conf.in	2012-07-18 08:19:16.000000000 +0200
@@ -76,6 +76,14 @@
 ; Default Value: 0
 ; process.max = 128
 
+; Specify the nice(2) priority to apply to the master process (only if set)
+; The value can vary from -19 (highest priority) to 20 (lower priority)
+; Note: - It will only work if the FPM master process is launched as root
+;       - The pool process will inherit the master process priority
+;         unless it specified otherwise
+; Default Value: no set
+; process.priority = -19
+
 ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
 ; Default Value: yes
 ;daemonize = yes
@@ -163,6 +171,14 @@ listen = 127.0.0.1:9000
 ; Default Value: any
 ;listen.allowed_clients = 127.0.0.1
 
+; Specify the nice(2) priority to apply to the pool processes (only if set)
+; The value can vary from -19 (highest priority) to 20 (lower priority)
+; Note: - It will only work if the FPM master process is launched as root
+;       - The pool processes will inherit the master process priority
+;         unless it specified otherwise
+; Default Value: no set
+; priority = -19
+
 ; Choose how the process manager will control the number of child processes.
 ; Possible Values:
 ;   static  - a fixed number (pm.max_children) of child processes;
diff -urNapw php-5.4.4/Zend/zend_compile.c php-5.4.5/Zend/zend_compile.c
--- php-5.4.4/Zend/zend_compile.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/Zend/zend_compile.c	2012-07-18 08:19:16.000000000 +0200
@@ -3619,6 +3619,7 @@ ZEND_API void zend_do_implement_trait(ze
 			}
 		}
 		ce->traits[ce->num_traits++] = trait;
+		trait->refcount++;
 	}
 }
 /* }}} */
@@ -3870,8 +3871,8 @@ static int zend_traits_copy_functions(ze
 				fn_copy = *fn;
 				function_add_ref(&fn_copy);
 				/* this function_name is never destroyed, because its refcount
-				   greater than 1, classes are always destoyed in reverse order
-				   and trait is declared early than this class */
+				   greater than 1 and classes are always destoyed before the
+				   traits they use */
 				fn_copy.common.function_name = aliases[i]->alias;
 					
 				/* if it is 0, no modifieres has been changed */
@@ -4076,14 +4077,14 @@ static void zend_do_traits_method_bindin
 	size_t i;
 
 	/* prepare copies of trait function tables for combination */
-	function_tables = malloc(sizeof(HashTable*) * ce->num_traits);
-	resulting_table = (HashTable *) malloc(sizeof(HashTable));
+	function_tables = emalloc(sizeof(HashTable*) * ce->num_traits);
+	resulting_table = (HashTable *)emalloc(sizeof(HashTable));
 	
 	/* TODO: revisit this start size, may be its not optimal */
-	zend_hash_init_ex(resulting_table, 10, NULL, NULL, 1, 0);
+	zend_hash_init_ex(resulting_table, 10, NULL, NULL, 0, 0);
   
 	for (i = 0; i < ce->num_traits; i++) {
-		function_tables[i] = (HashTable *) malloc(sizeof(HashTable));
+		function_tables[i] = (HashTable *)emalloc(sizeof(HashTable));
 		zend_hash_init_ex(function_tables[i], ce->traits[i]->function_table.nNumOfElements, NULL, NULL, 1, 0);
 
 		if (ce->trait_precedences) {
@@ -4116,14 +4117,14 @@ static void zend_do_traits_method_bindin
 	for (i = 0; i < ce->num_traits; i++) {
 		/* zend_hash_destroy(function_tables[i]); */
 		zend_hash_graceful_destroy(function_tables[i]);
-		free(function_tables[i]);
+		efree(function_tables[i]);
 	}
-	free(function_tables);
+	efree(function_tables);
 
 	/* free temporary resulting table */
 	/* zend_hash_destroy(resulting_table); */
 	zend_hash_graceful_destroy(resulting_table);
-	free(resulting_table);
+	efree(resulting_table);
 }
 /* }}} */
 
diff -urNapw php-5.4.4/Zend/zend_hash.h php-5.4.5/Zend/zend_hash.h
--- php-5.4.4/Zend/zend_hash.h	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/Zend/zend_hash.h	2012-07-18 08:19:16.000000000 +0200
@@ -330,7 +330,7 @@ END_EXTERN_C()
 				if (idx-1 > LONG_MAX) { /* overflow */						\
 					break;													\
 				}															\
-				idx = (ulong)(-(long)idx);									\
+				idx = -idx;               									\
 			} else if (idx > LONG_MAX) { /* overflow */						\
 				break;														\
 			}																\
--- php-5.4.4/Zend/zend_ini_scanner.l	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/Zend/zend_ini_scanner.l	2012-07-18 08:19:16.000000000 +0200
@@ -347,7 +347,7 @@ DOLLAR_CURLY "${"
 
 SECTION_RAW_CHARS [^\]\n\r]
 SINGLE_QUOTED_CHARS [^']
-RAW_VALUE_CHARS [^\n\r;\000]
+RAW_VALUE_CHARS [^"\n\r;\000]
 
 LITERAL_DOLLAR ("$"([^{\000]|("\\"{ANY_CHAR})))
 VALUE_CHARS         ([^$= \t\n\r;&|~()!"'\000]|{LITERAL_DOLLAR})
@@ -445,12 +445,33 @@ SECTION_VALUE_CHARS ([^$\n\r;"'\]\\]|("\
 	return '=';
 }
 
-<ST_RAW>{RAW_VALUE_CHARS}+ { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
-	/* Eat leading and trailing double quotes */
-	if (yytext[0] == '"' && yytext[yyleng - 1] == '"') {
+<ST_RAW>["] {
+	while (YYCURSOR < YYLIMIT) {
+		switch (*YYCURSOR++) {
+			case '\n':
+				SCNG(lineno)++;
+				break;
+			case '\r':
+				if (*YYCURSOR != '\n') {
+					SCNG(lineno)++;
+				}
+				break;
+			case '"':
+				yyleng = YYCURSOR - SCNG(yy_text) - 2;
 		SCNG(yy_text)++;
-		yyleng = yyleng - 2;
+				RETURN_TOKEN(TC_RAW, yytext, yyleng);
+			case '\\':
+				if (YYCURSOR < YYLIMIT) {
+					YYCURSOR++;
 	}
+				break;
+		}
+	}
+	yyleng = YYCURSOR - SCNG(yy_text);
+	RETURN_TOKEN(TC_RAW, yytext, yyleng);
+}
+
+<ST_RAW>{RAW_VALUE_CHARS}+ { /* Raw value, only used when SCNG(scanner_mode) == ZEND_INI_SCANNER_RAW. */
 	RETURN_TOKEN(TC_RAW, yytext, yyleng);
 }
 
diff -urNapw php-5.4.4/Zend/zend_language_parser.c php-5.4.5/Zend/zend_language_parser.c
--- php-5.4.4/Zend/zend_language_parser.c	2012-06-13 08:08:08.000000000 +0200
+++ php-5.4.5/Zend/zend_language_parser.c	2012-07-18 09:27:09.000000000 +0200
@@ -6041,7 +6041,7 @@ static YYSIZE_T zend_yytnamerr(char *yyr
 
 			if (LANG_SCNG(yy_text)[0] == 0 &&
 				LANG_SCNG(yy_leng) == 1 &&
-				memcmp(yystr, ZEND_STRL("\"end of file\"")) == 0) {
+				memcmp(yystr, "\"end of file\"", sizeof("\"end of file\"") - 1) == 0) {
 				yystpcpy(yyres, "end of file");
 				return sizeof("end of file")-1;
 			}
diff -urNapw php-5.4.4/Zend/zend_language_parser.y php-5.4.5/Zend/zend_language_parser.y
--- php-5.4.4/Zend/zend_language_parser.y	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/Zend/zend_language_parser.y	2012-07-18 08:19:16.000000000 +0200
@@ -1191,7 +1191,7 @@ static YYSIZE_T zend_yytnamerr(char *yyr
 
 			if (LANG_SCNG(yy_text)[0] == 0 &&
 				LANG_SCNG(yy_leng) == 1 &&
-				memcmp(yystr, ZEND_STRL("\"end of file\"")) == 0) {
+				memcmp(yystr, "\"end of file\"", sizeof("\"end of file\"") - 1) == 0) {
 				yystpcpy(yyres, "end of file");
 				return sizeof("end of file")-1;
 			}
diff -urNapw php-5.4.4/Zend/zend_multibyte.c php-5.4.5/Zend/zend_multibyte.c
--- php-5.4.4/Zend/zend_multibyte.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/Zend/zend_multibyte.c	2012-07-18 08:19:16.000000000 +0200
@@ -168,7 +168,7 @@ ZEND_API const zend_encoding *zend_multi
 ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size TSRMLS_DC)
 {
 	if (CG(script_encoding_list)) {
-		efree(CG(script_encoding_list));
+		free(CG(script_encoding_list));
 	}
 	CG(script_encoding_list) = encoding_list;
 	CG(script_encoding_list_size) = encoding_list_size;
diff -urNapw php-5.4.4/Zend/zend_opcode.c php-5.4.5/Zend/zend_opcode.c
--- php-5.4.4/Zend/zend_opcode.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/Zend/zend_opcode.c	2012-07-18 08:19:16.000000000 +0200
@@ -215,6 +215,12 @@ ZEND_API int zend_cleanup_class_data(zen
 void _destroy_zend_class_traits_info(zend_class_entry *ce)
 {
 	if (ce->num_traits > 0 && ce->traits) {
+		size_t i;
+		for (i = 0; i < ce->num_traits; i++) {
+			if (ce->traits[i]) {
+				destroy_zend_class(&ce->traits[i]);
+			}
+		}
 		efree(ce->traits);
 	}
 	
diff -urNapw php-5.4.4/Zend/zend_operators.c php-5.4.5/Zend/zend_operators.c
--- php-5.4.4/Zend/zend_operators.c	2012-06-13 06:54:23.000000000 +0200
+++ php-5.4.5/Zend/zend_operators.c	2012-07-18 08:19:16.000000000 +0200
@@ -1605,7 +1605,8 @@ ZEND_API int is_identical_function(zval
 				&& (!memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1))));
 			break;
 		case IS_ARRAY:
-			Z_LVAL_P(result) = zend_hash_compare(Z_ARRVAL_P(op1), Z_ARRVAL_P(op2), (compare_func_t) hash_zval_identical_function, 1 TSRMLS_CC)==0;
+			Z_LVAL_P(result) = (Z_ARRVAL_P(op1) == Z_ARRVAL_P(op2) ||
+				zend_hash_compare(Z_ARRVAL_P(op1), Z_ARRVAL_P(op2), (compare_func_t) hash_zval_identical_function, 1 TSRMLS_CC)==0);
 			break;
 		case IS_OBJECT:
 			if (Z_OBJ_HT_P(op1) == Z_OBJ_HT_P(op2)) {
@@ -2097,13 +2098,13 @@ static int hash_zval_compare_function(co
 
 ZEND_API int zend_compare_symbol_tables_i(HashTable *ht1, HashTable *ht2 TSRMLS_DC) /* {{{ */
 {
-	return zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC);
+	return ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC);
 }
 /* }}} */
 
 ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC) /* {{{ */
 {
-	ZVAL_LONG(result, zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC));
+	ZVAL_LONG(result, ht1 == ht2 ? 0 : zend_hash_compare(ht1, ht2, (compare_func_t) hash_zval_compare_function, 0 TSRMLS_CC));
 }
 /* }}} */
 

Reply to: