]> granicus.if.org Git - php/commitdiff
- Fix crash bug (patch by <chocolateboy@lunomail.com>)
authorDerick Rethans <derick@php.net>
Mon, 24 Sep 2001 08:33:51 +0000 (08:33 +0000)
committerDerick Rethans <derick@php.net>
Mon, 24 Sep 2001 08:33:51 +0000 (08:33 +0000)
ext/standard/string.c

index 30302c05c1d1232f8d6c47f85ca7d3fe5bf85ce1..c8088dabc678e67ae73e9bbb35eab38fd445a78d 100644 (file)
@@ -2990,6 +2990,11 @@ PHP_FUNCTION(nl2br)
        
        convert_to_string_ex(str);
 
+       /* bail out if the string is empty */
+       if (Z_STRLEN_PP(str) == 0) {
+               RETURN_EMPTY_STRING();
+       }
+       
        /* Windows style line-endings */
        tmp = php_str_to_str((*str)->value.str.val, (*str)->value.str.len, "\r\n", 2, "<br />\r\n", 8, &new_length);
        if (new_length != (*str)->value.str.len)