]> granicus.if.org Git - php/commitdiff
Fixed trim()'s memory leak in unicode mode
authorDmitry Stogov <dmitry@php.net>
Mon, 15 Aug 2005 08:11:35 +0000 (08:11 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 15 Aug 2005 08:11:35 +0000 (08:11 +0000)
ext/standard/string.c

index 1b9cff5398dedf136392332240c2ebd54e4c3bac..5b67852569bebe44124b0b1637171a1b6d643f96 100644 (file)
@@ -713,17 +713,18 @@ static UChar *php_u_trim(UChar *c, int32_t len, UChar *what, int32_t what_len, z
        if ( start < len ) {
                if ( return_value ) {
                        RETVAL_UNICODEL(c+start, end-start+1, 1);
+                       return NULL;
                } else {
                        return eustrndup(c+start, end-start+1);
                }
        } else { /* Trimmed the whole string */
                if ( return_value ) {
                        RETVAL_EMPTY_UNICODE();
+                       return NULL;
                } else {
                        return (USTR_MAKE(""));
                }
        }
-       return (USTR_MAKE(""));
 }
 /* }}} */