public inbox for linux-msdos@vger.kernel.org
 help / color / mirror / Atom feed
* A rather special bug?
@ 2003-03-25  6:56 Stephan Brauss
  0 siblings, 0 replies; only message in thread
From: Stephan Brauss @ 2003-03-25  6:56 UTC (permalink / raw)
  To: linux-msdos

Hello!

I think that I have found a bug that is present at least in dosemu-1.0.2.
Compile the appended program, run it and press any key while
the memory testing loop is running. You will see that one byte of the
allocated memory blocks is altered and now contains the ascii code of 
the pressed character. Can someone reproduce this problem? Is it fixed
in newer dosemu versions?

Stephan

----------------------

#include <stdio.h>
#include <stdlib.h>

#define SEGMENTS 7
#define SIZE 65500

int *segments[SEGMENTS];

int main()
{
	int i,j,k;

	for(i=0;i<SEGMENTS;i++)
	{
		printf("malloc segment %d\n",i+1);
		segments[i]=(int *)malloc(SIZE);
		if(segments[i]==NULL)
		{
			printf("malloc error\n");
			exit(1);
		}
		for(j=0;j<SIZE/sizeof(int);j++)
			segments[i][j]=0;
	}

	k=1;
	for(;;)
	{
		printf("loop: %d\n",k);
		for(i=0;i<SEGMENTS;i++)
		{
			for(j=0;j<SIZE/sizeof(int);j++)
			{
				if(segments[i][j]!=0)
				{
					printf("segments[%d][%d]=%d\n",i,j,segments[i][j]);
				}
			}
		}
		k++;
	}
	return 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-03-25  6:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-03-25  6:56 A rather special bug? Stephan Brauss

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox