Page 1 of 1

Fatal error: Possible integer overflow in memory allocation

Posted: Tue Apr 18, 2006 6:48 pm
by eprom
hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


G'day

Got a bizzare issue with PHP 5.0.2/Apache constantly generating variations of the following error:

"Fatal error: Possible integer overflow in memory allocation"

At first I traced it through to any line using the $_SERVER[] command and so replaced it with $HTTP_SERVER_VARS[]. This worked fine, however now I seem to get the issue whenever I use a "preg_match" command.

Is there some greater global variable/configuration item that I need to sort out to stop this from happening or is it something else?

For example, trying to implement a VERY basic PHP image gallery script, the  following function errors on the "if (preg_match" line - as have several other scripts.

Code: Select all

function GetFileList($dirname="."){
	global $config;
	$list = array(); 

	if ($handle = opendir($dirname)) {
		while (false !== ($file = readdir($handle))) { 
			if (preg_match("/\.(jpeg|gif|png)$/i",$file)) { 	
				$list[] = $file;
			} 
		}
		closedir($handle); 
	}
	sort($list);

	return $list;
}#-#GetFileList()
Any help would be GREATLY appreciated!

Thanks in advance

Chris


hawleyjr | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Tue Apr 18, 2006 8:31 pm
by shiznatix
very strange. how big is this initial directory? how many times do you call this function?

Posted: Tue Apr 18, 2006 8:56 pm
by eprom
shiznatix wrote:very strange. how big is this initial directory? how many times do you call this function?
Hi Shiznatix,

The directory currently has 5 JPG files in it, have tried a number of combinations of files, file names etc. This is the first time the function has been called.

My concern is that the problem is something bigger than just the preg_match due to it occuring on the $SERVER command as well.

any help would be greatly appreciated!

Posted: Tue Apr 18, 2006 9:07 pm
by feyd
how much code is run before the posted snippet?

Posted: Tue Apr 18, 2006 9:07 pm
by shiznatix
how big are these files? what is this global $config var that you dont use?

Posted: Tue Apr 18, 2006 9:14 pm
by eprom
shiznatix wrote:how big are these files? what is this global $config var that you dont use?
The files range in size from 600kb to 2.4mb

I replaced, for example, $SERVER[HTTP_REFERER] with $HTTP_SERVER_VARS[HTTP_REFERER]