corona/src/Convert.cpp:
The ConvertPixels function crashes when you have low memory... Because ConvertPixels doesn't check if the 'out' parameter is valid...
Fix by adding checks for NULL to the method...
////////////////////////////
bool ConvertPixels(byte* out, PixelFormat out_format,
const byte* in, PixelFormat in_format,
int pixel_count)
{
// added checks...
if (!out || !in) {
return false;
}
const FormatDesc* out_desc = GetDescription(out_format);
const FormatDesc* in_desc = GetDescription(in_format);
if (!out_desc || !in_desc) {
return false;
}
const int out_size = GetPixelSize(out_format);
const int in_size = GetPixelSize(in_format);
for (int i = 0; i < pixel_count; ++i) {
out[out_desc->r_shift] = in[in_desc->r_shift];
out[out_desc->g_shift] = in[in_desc->g_shift];
out[out_desc->b_shift] = in[in_desc->b_shift];
if (out_desc->has_alpha) {
if (in_desc->has_alpha) {
out[out_desc->a_shift] = in[in_desc->a_shift];
} else {
out[out_desc->a_shift] = 255;
}
}
in += in_size;
out += out_size;
}
return true;
}
////////////////////////////
Note that ConvertPixels is called with the out parameter being checked in the same source file, so the bug is valid...
- Flik
A diff for the patch