felipe                                   Tue, 22 Nov 2011 12:29:15 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=319676

Log:
- Fixed memory leak in several Intl locale functions

Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/intl/locale/locale_methods.c
    U   php/php-src/branches/PHP_5_4/NEWS
    U   php/php-src/branches/PHP_5_4/ext/intl/locale/locale_methods.c
    U   php/php-src/trunk/ext/intl/locale/locale_methods.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2011-11-22 11:03:30 UTC (rev 319675)
+++ php/php-src/branches/PHP_5_3/NEWS	2011-11-22 12:29:15 UTC (rev 319676)
@@ -30,6 +30,7 @@
 - Intl:
   . Fixed bug #60192 (SegFault when Collator not constructed
     properly). (Florian)
+  . Fixed memory leak in several Intl locale functions. (Felipe)

 - Gd:
   . Fixed bug #60160 (imagefill() doesn't work correctly

Modified: php/php-src/branches/PHP_5_3/ext/intl/locale/locale_methods.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/intl/locale/locale_methods.c	2011-11-22 11:03:30 UTC (rev 319675)
+++ php/php-src/branches/PHP_5_3/ext/intl/locale/locale_methods.c	2011-11-22 12:29:15 UTC (rev 319676)
@@ -470,6 +470,7 @@

 	char*       disp_loc_name       = NULL;
 	int         disp_loc_name_len   = 0;
+	int         free_loc_name       = 0;

 	UChar*      disp_name      	= NULL;
 	int32_t     disp_name_len  	= 0;
@@ -517,17 +518,18 @@
 	if( mod_loc_name==NULL ){
 		mod_loc_name = estrdup( loc_name );
 	}
+
+	/* Check if disp_loc_name passed , if not use default locale */
+	if( !disp_loc_name){
+		disp_loc_name = estrdup(INTL_G(default_locale));
+		free_loc_name = 1;
+	}

     /* Get the disp_value for the given locale */
     do{
         disp_name = erealloc( disp_name , buflen  );
         disp_name_len = buflen;

-        /* Check if disp_loc_name passed , if not use default locale */
-        if( !disp_loc_name){
-            disp_loc_name = estrdup(INTL_G(default_locale));
-        }
-
 		if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
 			buflen = uloc_getDisplayLanguage ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
 		} else if( strcmp(tag_name , LOC_SCRIPT_TAG)==0 ){
@@ -557,6 +559,10 @@
 			if( mod_loc_name){
 				efree( mod_loc_name );
 			}
+			if (free_loc_name) {
+				efree(disp_loc_name);
+				disp_loc_name = NULL;
+			}
 			RETURN_FALSE;
 		}
 	} while( buflen > disp_name_len );
@@ -564,6 +570,10 @@
 	if( mod_loc_name){
 		efree( mod_loc_name );
 	}
+	if (free_loc_name) {
+		efree(disp_loc_name);
+		disp_loc_name = NULL;
+	}
 	/* Convert display locale name from UTF-16 to UTF-8. */
 	intl_convert_utf16_to_utf8( &utf8value, &utf8value_len, disp_name, buflen, &status );
 	efree( disp_name );

Modified: php/php-src/branches/PHP_5_4/NEWS
===================================================================
--- php/php-src/branches/PHP_5_4/NEWS	2011-11-22 11:03:30 UTC (rev 319675)
+++ php/php-src/branches/PHP_5_4/NEWS	2011-11-22 12:29:15 UTC (rev 319676)
@@ -17,6 +17,27 @@
   . Fixed bug #43200 (Interface implementation / inheritence not possible in
     abstract classes). (Felipe)

+- CLI SAPI:
+  . Fixed bug #60159 (Router returns false, but POST is not passed to requested
+    resource). (Laruence)
+  . Fixed bug #55759 (memory leak when using built-in server). (Laruence)
+
+- Improved PHP-FPM SAPI:
+  . Enhance error log when the primary script can't be open. FR #60199. (fat)
+  . Remove EXPERIMENTAL flag. (fat)
+  . Added .phar to default authorized extensions. (fat)
+
+- BCmath:
+  . Fixed bug #60377 (bcscale related crashes on 64bits platforms) (shm)
+
+- Intl:
+  . Fixed memory leak in several Intl locale functions. (Felipe)
+
+- Mbstring
+  . Fixed bug #60306 (Characters lost while converting from cp936 to utf8).
+    (Laruence)
+  . Fixed possible crash in mb_ereg_search_init() using empty pattern. (Felipe)
+
 - MS SQL:
   . Fixed bug #60267 (Compile failure with freetds 0.91). (Felipe)

@@ -35,35 +56,17 @@
   . Fixed bug #60282 (Segfault when using ob_gzhandler() with open buffers).
     (Laruence)

+- Reflection:
+  . Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string
+    conversion"). (Laruence)
+
 - SOAP extension:
   . Added new SoapClient option "keep_alive". FR #60329. (Pierrick)
-
+
 - Tidy:
   . Fixed bug #54682 (Tidy::diagnose() NULL pointer dereference).
     (Maksymilian Arciemowicz, Felipe)

-- Mbstring
-  . Fixed bug #60306 (Characters lost while converting from cp936 to utf8).
-    (Laruence)
-  . Fixed possible crash in mb_ereg_search_init() using empty pattern. (Felipe)
-
-- CLI SAPI:
-  . Fixed bug #60159 (Router returns false, but POST is not passed to requested
-    resource). (Laruence)
-  . Fixed bug #55759 (memory leak when using built-in server). (Laruence)
-
-- Improved PHP-FPM SAPI:
-  . Enhance error log when the primary script can't be open. FR #60199. (fat)
-  . Remove EXPERIMENTAL flag. (fat)
-  . Added .phar to default authorized extensions. (fat)
-
-- BCmath:
-  . Fixed bug #60377 (bcscale related crashes on 64bits platforms) (shm)
-
-- Reflection:
-  . Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string
-    conversion"). (Laruence)
-
 11 Nov 2011, PHP 5.4.0 RC1
 - General improvements:
   . Changed silent conversion of array to string to produce a notice. (Patrick)

Modified: php/php-src/branches/PHP_5_4/ext/intl/locale/locale_methods.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/intl/locale/locale_methods.c	2011-11-22 11:03:30 UTC (rev 319675)
+++ php/php-src/branches/PHP_5_4/ext/intl/locale/locale_methods.c	2011-11-22 12:29:15 UTC (rev 319676)
@@ -470,6 +470,7 @@

 	char*       disp_loc_name       = NULL;
 	int         disp_loc_name_len   = 0;
+	int         free_loc_name       = 0;

 	UChar*      disp_name      	= NULL;
 	int32_t     disp_name_len  	= 0;
@@ -517,17 +518,18 @@
 	if( mod_loc_name==NULL ){
 		mod_loc_name = estrdup( loc_name );
 	}
+
+	/* Check if disp_loc_name passed , if not use default locale */
+	if( !disp_loc_name){
+		disp_loc_name = estrdup(INTL_G(default_locale));
+		free_loc_name = 1;
+	}

     /* Get the disp_value for the given locale */
     do{
         disp_name = erealloc( disp_name , buflen  );
         disp_name_len = buflen;

-        /* Check if disp_loc_name passed , if not use default locale */
-        if( !disp_loc_name){
-            disp_loc_name = estrdup(INTL_G(default_locale));
-        }
-
 		if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
 			buflen = uloc_getDisplayLanguage ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
 		} else if( strcmp(tag_name , LOC_SCRIPT_TAG)==0 ){
@@ -557,6 +559,10 @@
 			if( mod_loc_name){
 				efree( mod_loc_name );
 			}
+			if (free_loc_name) {
+				efree(disp_loc_name);
+				disp_loc_name = NULL;
+			}
 			RETURN_FALSE;
 		}
 	} while( buflen > disp_name_len );
@@ -564,6 +570,10 @@
 	if( mod_loc_name){
 		efree( mod_loc_name );
 	}
+	if (free_loc_name) {
+		efree(disp_loc_name);
+		disp_loc_name = NULL;
+	}
 	/* Convert display locale name from UTF-16 to UTF-8. */
 	intl_convert_utf16_to_utf8( &utf8value, &utf8value_len, disp_name, buflen, &status );
 	efree( disp_name );

Modified: php/php-src/trunk/ext/intl/locale/locale_methods.c
===================================================================
--- php/php-src/trunk/ext/intl/locale/locale_methods.c	2011-11-22 11:03:30 UTC (rev 319675)
+++ php/php-src/trunk/ext/intl/locale/locale_methods.c	2011-11-22 12:29:15 UTC (rev 319676)
@@ -470,6 +470,7 @@

 	char*       disp_loc_name       = NULL;
 	int         disp_loc_name_len   = 0;
+	int         free_loc_name       = 0;

 	UChar*      disp_name      	= NULL;
 	int32_t     disp_name_len  	= 0;
@@ -517,17 +518,18 @@
 	if( mod_loc_name==NULL ){
 		mod_loc_name = estrdup( loc_name );
 	}
+
+	/* Check if disp_loc_name passed , if not use default locale */
+	if( !disp_loc_name){
+		disp_loc_name = estrdup(INTL_G(default_locale));
+		free_loc_name = 1;
+	}

     /* Get the disp_value for the given locale */
     do{
         disp_name = erealloc( disp_name , buflen  );
         disp_name_len = buflen;

-        /* Check if disp_loc_name passed , if not use default locale */
-        if( !disp_loc_name){
-            disp_loc_name = estrdup(INTL_G(default_locale));
-        }
-
 		if( strcmp(tag_name , LOC_LANG_TAG)==0 ){
 			buflen = uloc_getDisplayLanguage ( mod_loc_name , disp_loc_name , disp_name , disp_name_len , &status);
 		} else if( strcmp(tag_name , LOC_SCRIPT_TAG)==0 ){
@@ -557,6 +559,10 @@
 			if( mod_loc_name){
 				efree( mod_loc_name );
 			}
+			if (free_loc_name) {
+				efree(disp_loc_name);
+				disp_loc_name = NULL;
+			}
 			RETURN_FALSE;
 		}
 	} while( buflen > disp_name_len );
@@ -564,6 +570,10 @@
 	if( mod_loc_name){
 		efree( mod_loc_name );
 	}
+	if (free_loc_name) {
+		efree(disp_loc_name);
+		disp_loc_name = NULL;
+	}
 	/* Convert display locale name from UTF-16 to UTF-8. */
 	intl_convert_utf16_to_utf8( &utf8value, &utf8value_len, disp_name, buflen, &status );
 	efree( disp_name );
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to