Bug 6964

Summary: The mem_limit() function is suspicious
Product: Xtests Reporter: Jiri Dluhos <jdluhos>
Component: XTSAssignee: Stuart Anderson <anderson>
Status: RESOLVED MOVED QA Contact: Xorg testing team <xorg-test>
Severity: normal    
Priority: high    
Version: unspecified   
Hardware: x86 (IA32)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Jiri Dluhos 2006-05-18 23:48:22 UTC
The mem_limit() function, in libXtTest/avs_func.c, is very hard to comprehend,
and I suspect it may be incorrect on Linux because malloc() is not guaranteed to
return NULL when there is not enough memory.

The code looks like this:

size_t
mem_limit()
{
	char	*ptr;
	size_t	hbit,i,j;

	j = 0;
	for (hbit=(((size_t)-1)>>1)+1;hbit;hbit=(ptr)?(i>>1):(i>>2)){
		for(i=1;
			(ptr=malloc(i|j)) && (free(ptr),1) && (i<hbit);
		i<<=1);
			j |= (ptr) ? i : i >> 1;
	}
	return(j);
}
Comment 1 chemtech 2013-03-15 14:07:36 UTC
Jiri Dluhos
Do you still experience this issue with newer drivers ?
Please check the status of your issue.
Comment 2 GitLab Migration User 2018-08-10 21:43:13 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/test/xts/issues/7.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.