diff options
author | sfan5 <sfan5@live.de> | 2022-03-02 17:46:27 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-05-14 18:33:42 +0200 |
commit | d569dc45a8f572059937d236ef54130ba6ff635b (patch) | |
tree | da48085593a8a67be97598e224ba63e0872f1ae7 /src | |
parent | 23d49fda294b84b263f4ebb5c3b900ee17468f9e (diff) | |
download | minetest-d569dc45a8f572059937d236ef54130ba6ff635b.tar.gz minetest-d569dc45a8f572059937d236ef54130ba6ff635b.tar.bz2 minetest-d569dc45a8f572059937d236ef54130ba6ff635b.zip |
Fix segfault with autoscale_mode (again)
closes #12100
This time add some asserts so there is no misunderstanding about the NULL-ness of layer->texture.
Diffstat (limited to 'src')
-rw-r--r-- | src/nodedef.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp index 1dd130ece..4bbc90845 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -675,7 +675,7 @@ static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer, bool has_scale = tiledef.scale > 0; bool use_autoscale = tsettings.autoscale_mode == AUTOSCALE_FORCE || (tsettings.autoscale_mode == AUTOSCALE_ENABLE && !has_scale); - if (use_autoscale) { + if (use_autoscale && layer->texture) { auto texture_size = layer->texture->getOriginalSize(); float base_size = tsettings.node_texture_size; float size = std::fmin(texture_size.Width, texture_size.Height); @@ -711,6 +711,7 @@ static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer, // Animation parameters int frame_count = 1; if (layer->material_flags & MATERIAL_FLAG_ANIMATION) { + assert(layer->texture); int frame_length_ms; tiledef.animation.determineParams(layer->texture->getOriginalSize(), &frame_count, &frame_length_ms, NULL); @@ -721,14 +722,13 @@ static void fillTileAttribs(ITextureSource *tsrc, TileLayer *layer, if (frame_count == 1) { layer->material_flags &= ~MATERIAL_FLAG_ANIMATION; } else { - std::ostringstream os(std::ios::binary); - if (!layer->frames) { + assert(layer->texture); + if (!layer->frames) layer->frames = new std::vector<FrameSpec>(); - } layer->frames->resize(frame_count); + std::ostringstream os(std::ios::binary); for (int i = 0; i < frame_count; i++) { - FrameSpec frame; os.str(""); |