Fix wrong step size in wxImage::Paste()
Fix a bug with wrong size passed to memset() introduced in 1f0ade29f0
(Fix using mask colour even if there is no mask in wxImage::Paste,
2020-09-30) which caused memory corruption and add a test (the one with
the large negative vertical offset) allowing to reproduce this reliably.
Closes https://github.com/wxWidgets/wxWidgets/pull/2067
This commit is contained in:
committed by
Vadim Zeitlin
parent
0c3494592a
commit
ec8bfbebdc
@@ -1764,7 +1764,7 @@ wxImage::Paste(const wxImage & image, int x, int y,
|
|||||||
// Make all the copied pixels fully opaque
|
// Make all the copied pixels fully opaque
|
||||||
if (alpha_target_data != NULL)
|
if (alpha_target_data != NULL)
|
||||||
{
|
{
|
||||||
memset(alpha_target_data, wxALPHA_OPAQUE, target_alpha_step);
|
memset(alpha_target_data, wxALPHA_OPAQUE, width);
|
||||||
alpha_target_data += target_alpha_step;
|
alpha_target_data += target_alpha_step;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1839,6 +1839,21 @@ TEST_CASE("wxImage::Paste", "[image][paste]")
|
|||||||
CHECK_THAT(actual, CenterAlphaPixelEquals(255));
|
CHECK_THAT(actual, CenterAlphaPixelEquals(255));
|
||||||
CHECK_THAT(actual, RGBSameAs(black));
|
CHECK_THAT(actual, RGBSameAs(black));
|
||||||
}
|
}
|
||||||
|
SECTION("Paste large image with negative vertical offset")
|
||||||
|
{
|
||||||
|
wxImage target(442, 249);
|
||||||
|
wxImage to_be_pasted(345, 24900);
|
||||||
|
target.InitAlpha();
|
||||||
|
target.Paste(to_be_pasted, 48, -12325, wxIMAGE_ALPHA_BLEND_COMPOSE);
|
||||||
|
}
|
||||||
|
SECTION("Paste large image with negative horizontal offset")
|
||||||
|
{
|
||||||
|
wxImage target(249, 442);
|
||||||
|
wxImage to_be_pasted(24900, 345);
|
||||||
|
target.InitAlpha();
|
||||||
|
target.Paste(to_be_pasted, -12325, 48, wxIMAGE_ALPHA_BLEND_COMPOSE);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user