Mantis - Quercus
Viewing Issue Advanced Details
5354 minor always 01-01-13 06:12 01-01-13 12:11
cowan  
nam  
normal  
closed 4.0.34  
fixed  
none    
none 4.0.35  
0005354: OutOfMemory with UserCake Captcha
The following code, from the UserCake project, causes:

"WarningService: Shutdown: TcpSocketLink OutOfMemory"

Something throws an OutOfMemoryException due to out of heap memory. It happens consistently on Resin Pro 4.0.34.

I'm not positive it's a Quercus bug, but this code looks fairly insignificant, so I suspect there is some issue in Quercus that causes the problem not the UserCake code.

/*
UserCake Version: 2.0.1
http://usercake.com [^]
*/
session_start();
$md5_hash = md5(rand(0,99999));
$security_code = substr($md5_hash, 25, 5);
$enc = md5($security_code);
$_SESSION['captcha'] = $enc;

$width = 150;
$height = 30;

$image = ImageCreate($width, $height);
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$grey = ImageColorAllocate($image, 200, 200, 200);

ImageFill($image, 0, 0, $white);
ImageString($image, 10, 5, 0, $security_code, $black);

header("Content-Type: image/png");
ImagePng($image);
ImageDestroy($image);
ImageDestroy($image);

?>



Notes
(0006171)
cowan   
01-01-13 06:14   
The code is models/captcha.php, which is used by registration.php to produce a captcha image.

(0006173)
nam   
01-01-13 12:11   
php/1p1j

Fixed for 4.0.35. Quercus wasn't properly handling fills where the start pixel's color is the same as the filling color (in effect doing nothing).

FYI, the first call to ImageColorAllocate() auto-fills the image with $white. So the call to imagefill() is redundant.