Commits

Bill Meltsner committed 32bf598

You can no longer access out-of-range pixels in ImageData

Comments (0)

Files changed (1)

src/modules/image/devil/ImageData.cpp

 	{
 		//int tx = x > width-1 ? width-1 : x;
 		//int ty = y > height-1 ? height-1 : y; // not using these seems to not break anything
+		if (x > width-1 || y > height-1 || x < 0 || y < 0) throw love::Exception("Attempt to set out-of-range pixel!");
 		pixel * pixels = (pixel *)getData();
 		pixels[y*width+x] = c;
 	}
 	{
 		//int tx = x > width-1 ? width-1 : x;
 		//int ty = y > height-1 ? height-1 : y; // not using these seems to not break anything
+		if (x > width-1 || y > height-1 || x < 0 || y < 0) throw love::Exception("Attempt to get out-of-range pixel!");
 		pixel * pixels = (pixel *)getData();
 		return pixels[y*width+x];
 	}