Fixed memory overwrite bug. This fixes the png writer and led control.

This commit is contained in:
T. van der Zwan
2013-08-03 23:24:22 +02:00
parent 240218a6bd
commit cbbb1d740b
11 changed files with 167 additions and 166 deletions

View File

@@ -10,19 +10,16 @@
RgbImage::RgbImage(const unsigned width, const unsigned height, const RgbColor background) :
mWidth(width),
mHeight(height),
mColors(nullptr)
mColors(new RgbColor[width*height])
{
mColors = new RgbColor[width*height];
for (RgbColor* color = mColors; color <= mColors+(mWidth*mHeight); ++color)
for (unsigned i=0; i<width*height; ++i)
{
*color = background;
mColors[i] = background;
}
}
RgbImage::~RgbImage()
{
std::cout << "RgbImage(" << this << ") is being deleted" << std::endl;
delete[] mColors;
}