mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Fix dividing by zero crashes in texture modifiers
This commit is contained in:
parent
2c390b5473
commit
2766c70ad3
@ -1598,6 +1598,13 @@ bool TextureSource::generateImagePart(std::string part_of_name,
|
||||
u32 frame_count = stoi(sf.next(":"));
|
||||
u32 frame_index = stoi(sf.next(":"));
|
||||
|
||||
if (frame_count == 0){
|
||||
errorstream << "generateImagePart(): invalid frame_count "
|
||||
<< "for part_of_name=\"" << part_of_name
|
||||
<< "\", using frame_count = 1 instead." << std::endl;
|
||||
frame_count = 1;
|
||||
}
|
||||
|
||||
if (baseimg == NULL){
|
||||
errorstream<<"generateImagePart(): baseimg != NULL "
|
||||
<<"for part_of_name=\""<<part_of_name
|
||||
@ -1899,6 +1906,13 @@ bool TextureSource::generateImagePart(std::string part_of_name,
|
||||
u32 x0 = stoi(sf.next(","));
|
||||
u32 y0 = stoi(sf.next(":"));
|
||||
|
||||
if (w0 == 0 || h0 == 0) {
|
||||
errorstream << "generateImagePart(): invalid width or height "
|
||||
<< "for part_of_name=\"" << part_of_name
|
||||
<< "\", cancelling." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
core::dimension2d<u32> img_dim = baseimg->getDimension();
|
||||
core::dimension2d<u32> tile_dim(v2u32(img_dim) / v2u32(w0, h0));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user