]> granicus.if.org Git - php/commitdiff
- Fixed possible efree(NULL) (bug #55296)
authorFelipe Pena <felipe@php.net>
Thu, 4 Aug 2011 00:59:43 +0000 (00:59 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 4 Aug 2011 00:59:43 +0000 (00:59 +0000)
ext/intl/collator/collator_compare.c
ext/intl/dateformat/dateformat_attr.c
ext/intl/formatter/formatter_attr.c
ext/intl/formatter/formatter_parse.c
ext/intl/grapheme/grapheme_string.c
ext/intl/grapheme/grapheme_util.c
ext/intl/idn/idn.c
ext/intl/msgformat/msgformat_attr.c
ext/intl/msgformat/msgformat_parse.c
ext/intl/normalizer/normalizer_normalize.c

index 4e7b3a7d4949f0a98b52aeebac7835e912b49dca..840855661cd63433a0a8bd53a7434de3d637a7fe 100755 (executable)
@@ -74,7 +74,9 @@ PHP_FUNCTION( collator_compare )
                /* Set error messages. */
                intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
                        "Error converting first argument to UTF-16", 0 TSRMLS_CC );
-               efree( ustr1 );
+               if (ustr1) {
+                       efree( ustr1 );
+               }
                RETURN_FALSE;
        }
 
@@ -88,8 +90,12 @@ PHP_FUNCTION( collator_compare )
                /* Set error messages. */
                intl_errors_set_custom_msg( COLLATOR_ERROR_P( co ),
                        "Error converting second argument to UTF-16", 0 TSRMLS_CC );
-               efree( ustr1 );
-               efree( ustr2 );
+               if (ustr1) {
+                       efree( ustr1 );
+               }
+               if (ustr2) {
+                       efree( ustr2 );
+               }
                RETURN_FALSE;
        }
 
index 7c6cef95360098ef24ebb54c4462620d6620dea8..6131cedc956b5fd156486b7d38ad33bb1c4a35a6 100755 (executable)
@@ -276,7 +276,9 @@ PHP_FUNCTION( datefmt_set_pattern )
 
        udat_applyPattern(DATE_FORMAT_OBJECT(dfo), (UBool)is_pattern_localized, svalue, slength);
 
-       efree(svalue);
+       if (svalue) {
+               efree(svalue);
+       }
        INTL_METHOD_CHECK_STATUS(dfo, "Error setting symbol value");
 
        RETURN_TRUE;
index 46d61fb1fce5807b5934716e39bbfbff34ec6a44..b306bbedeb9f4a265f044a280821b65505a3c8e5 100755 (executable)
@@ -233,7 +233,9 @@ PHP_FUNCTION( numfmt_set_text_attribute )
 
        /* Actually set new attribute value. */
        unum_setTextAttribute(FORMATTER_OBJECT(nfo), attribute, svalue, slength, &INTL_DATA_ERROR_CODE(nfo));
-       efree(svalue);
+       if (svalue) {
+               efree(svalue);
+       }
        INTL_METHOD_CHECK_STATUS( nfo, "Error setting text attribute" );
 
        RETURN_TRUE;
@@ -326,7 +328,9 @@ PHP_FUNCTION( numfmt_set_symbol )
 
        /* Actually set the symbol. */
        unum_setSymbol(FORMATTER_OBJECT(nfo), symbol, svalue, slength, &INTL_DATA_ERROR_CODE(nfo));
-       efree(svalue);
+       if (svalue) {
+               efree(svalue);
+       }
        INTL_METHOD_CHECK_STATUS( nfo, "Error setting symbol value" );
 
        RETURN_TRUE;
@@ -406,7 +410,9 @@ PHP_FUNCTION( numfmt_set_pattern )
 
        /* TODO: add parse error information */
        unum_applyPattern(FORMATTER_OBJECT(nfo), 0, svalue, slength, NULL, &INTL_DATA_ERROR_CODE(nfo));
-       efree(svalue);
+       if (svalue) {
+               efree(svalue);
+       }
        INTL_METHOD_CHECK_STATUS( nfo, "Error setting pattern value" );
 
        RETURN_TRUE;
index b73095d3e4e7c6fe4a2e1d5918127e73289f8b09..cbdde855dece8def0ffd25419d9c58e1635bd8f4 100755 (executable)
@@ -107,7 +107,9 @@ PHP_FUNCTION( numfmt_parse )
                ZVAL_LONG(zposition, position);
        }
 
-       efree(sstr);
+       if (sstr) {
+               efree(sstr);
+       }
 
        INTL_METHOD_CHECK_STATUS( nfo, "Number parsing failed" );
 }
@@ -161,7 +163,9 @@ PHP_FUNCTION( numfmt_parse_currency )
                zval_dtor(zposition);
                ZVAL_LONG(zposition, position);
        }
-       efree(sstr);
+       if (sstr) {
+               efree(sstr);
+       }
        INTL_METHOD_CHECK_STATUS( nfo, "Number parsing failed" );
 
        /* Convert parsed currency to UTF-8 and pass it back to caller. */
index 1784d028a8beae06627e0ab5fdeebb281f4820d1..095cc2a0466cad6f6fb461c2320081673732788d 100755 (executable)
@@ -84,13 +84,17 @@ PHP_FUNCTION(grapheme_strlen)
 
                /* Set error messages. */
                intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-               efree( ustring );
+               if (ustring) {
+                       efree( ustring );
+               }
                RETURN_NULL();
        }
 
        ret_len = grapheme_split_string(ustring, ustring_len, NULL, 0 TSRMLS_CC );
 
-       efree( ustring );
+       if (ustring) {
+               efree( ustring );
+       }
 
        if (ret_len >= 0) {
                RETVAL_LONG(ret_len);
@@ -447,7 +451,9 @@ PHP_FUNCTION(grapheme_substr)
 
                /* Set error messages. */
                intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-               efree( ustr );
+               if (ustr) {
+                       efree( ustr );
+               }
                RETURN_FALSE;
        }
 
@@ -485,7 +491,9 @@ PHP_FUNCTION(grapheme_substr)
 
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_substr: start not contained in string", 1 TSRMLS_CC );
 
-               efree(ustr);
+               if (ustr) {
+                       efree(ustr);
+               }
                ubrk_close(bi);
                RETURN_FALSE;
        }
@@ -499,7 +507,9 @@ PHP_FUNCTION(grapheme_substr)
                status = U_ZERO_ERROR;
                intl_convert_utf16_to_utf8((char **)&sub_str, &sub_str_len, ustr + sub_str_start_pos, ustr_len - sub_str_start_pos, &status);
 
-               efree( ustr );
+               if (ustr) {
+                       efree( ustr );
+               }
                ubrk_close( bi );
 
                if ( U_FAILURE( status ) ) {
@@ -509,6 +519,7 @@ PHP_FUNCTION(grapheme_substr)
                        /* Set error messages. */
                        intl_error_set_custom_msg( NULL, "Error converting output string to UTF-8", 0 TSRMLS_CC );
 
+                       
                        efree( sub_str );
 
                        RETURN_FALSE;
@@ -897,7 +908,9 @@ PHP_FUNCTION(grapheme_extract)
 
        ret_pos = (*grapheme_extract_iters[extract_type])(bi, size, pstr, str_len);
 
-       efree(ustr);
+       if (ustr) {
+               efree(ustr);
+       }
        ubrk_close(bi);
 
        if ( NULL != next ) {
index 1978d274a0fd3b2b9f207ab8be2d3cff83fd9796..db5643164859912dd7315eb910fbd58b6eddaa80 100755 (executable)
@@ -170,7 +170,9 @@ grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned c
 
         /* Set error messages. */
         intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-        efree( uhaystack );
+        if (uhaystack) {
+                       efree( uhaystack );
+               }
         return -1;
     }
 
@@ -187,7 +189,9 @@ grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned c
 
     if ( NULL == puhaystack ) {
         intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 TSRMLS_CC );
-        efree( uhaystack );
+        if (uhaystack) {
+                       efree( uhaystack );
+               }
         ubrk_close (bi);
         return -1;
     }
@@ -203,8 +207,12 @@ grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned c
 
         /* Set error messages. */
         intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-        efree( uhaystack );
-        efree( uneedle );
+        if (uhaystack) {
+                       efree( uhaystack );
+               }
+               if (uneedle) {
+                       efree( uneedle );
+               }
         ubrk_close (bi);
         return -1;
     }
@@ -260,8 +268,12 @@ grapheme_strrpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned c
     }
 
 exit:
-    efree( uhaystack );
-    efree( uneedle );
+       if (uhaystack) {
+               efree( uhaystack );
+       }
+       if (uneedle) {
+               efree( uneedle );
+       }
     ubrk_close (bi);
 
     return ret_pos;
@@ -295,7 +307,9 @@ grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned ch
 
                /* Set error messages. */
                intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-               efree( uhaystack );
+               if (uhaystack) {
+                       efree( uhaystack );
+               }
                return -1;
        }
 
@@ -310,8 +324,9 @@ grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned ch
        if ( NULL == puhaystack ) {
        
                intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, "grapheme_strpos: Offset not contained in string", 1 TSRMLS_CC );
-               
-               efree( uhaystack );
+               if (uhaystack) {
+                       efree( uhaystack );
+               }
                ubrk_close (bi);
                                        
                return -1;
@@ -332,8 +347,12 @@ grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned ch
 
                /* Set error messages. */
                intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-               efree( uhaystack );
-               efree( uneedle );
+               if (uhaystack) {
+                       efree( uhaystack );
+               }
+               if (uneedle) {
+                       efree( uneedle );
+               }
                ubrk_close (bi);
                
                return -1;
@@ -347,8 +366,12 @@ grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned ch
        
        *puchar_pos = ubrk_current(bi);
 
-       efree( uhaystack );
-       efree( uneedle );
+       if (uhaystack) {
+               efree( uhaystack );
+       }
+       if (uneedle) {
+               efree( uneedle );
+       }
        ubrk_close (bi);
 
        return ret_pos;
index e7a3b6a6d2d962df4422a470b9421082490d9b9e..23cd0ea87244735b7bd7ebee54e20c0ab218df9c 100644 (file)
@@ -85,7 +85,9 @@ static void php_intl_idn_to(INTERNAL_FUNCTION_PARAMETERS, int mode)
 
                /* Set error messages. */
                intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-               efree(ustring);
+               if (ustring) {
+                       efree(ustring);
+               }
                RETURN_FALSE;
        } else {
                UParseError parse_error;
index 47350b2b451ed0b1a7f3f549eb0d25323b27c6c8..cf346651424b05884e91517e07bd95bbc47d87e0 100755 (executable)
@@ -90,7 +90,9 @@ PHP_FUNCTION( msgfmt_set_pattern )
 
        /* TODO: add parse error information */
        umsg_applyPattern(MSG_FORMAT_OBJECT(mfo), spattern, spattern_len, NULL, &INTL_DATA_ERROR_CODE(mfo));
-       efree(spattern);
+       if (spattern) {
+               efree(spattern);
+       }
        INTL_METHOD_CHECK_STATUS(mfo, "Error setting symbol value");
 
        if(mfo->mf_data.orig_format) {
index 61c5213f05ef6ce07df17fe4f315cd224e7285c4..8393d4c6e39585a43a9a13f18063757a1569ea4e 100755 (executable)
@@ -40,7 +40,9 @@ static void msgfmt_do_parse(MessageFormatter_object *mfo, char *source, int src_
        INTL_METHOD_CHECK_STATUS(mfo, "Converting parse string failed");
 
        umsg_parse_helper(MSG_FORMAT_OBJECT(mfo), &count, &fargs, usource, usrc_len, &INTL_DATA_ERROR_CODE(mfo));
-       efree(usource);
+       if (usource) {
+               efree(usource);
+       }
        INTL_METHOD_CHECK_STATUS(mfo, "Parsing failed");
 
        array_init(return_value);
index 482c4a01e5912b3e1859eaa361029311d2e6154a..466ab97e12c86afd461903c61abfa1e91f7b2200 100755 (executable)
@@ -96,7 +96,9 @@ PHP_FUNCTION( normalizer_normalize )
 
                /* Set error messages. */
                intl_error_set_custom_msg( NULL, "Error converting input string to UTF-16", 0 TSRMLS_CC );
-               efree( uinput );
+               if (uinput) {
+                       efree( uinput );
+               }
                RETURN_FALSE;
        }
 
@@ -220,7 +222,9 @@ PHP_FUNCTION( normalizer_is_normalized )
 
                /* Set error messages. */
                intl_error_set_custom_msg( NULL, "Error converting string to UTF-16.", 0 TSRMLS_CC );
-               efree( uinput );
+               if (uinput) {
+                       efree( uinput );
+               }
                RETURN_FALSE;
        }