Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

guiScalingFilter: prevent infinite loop caused by negative background9[] size #13624

Merged
merged 1 commit into from Jul 7, 2023

Conversation

SmallJoker
Copy link
Member

@SmallJoker SmallJoker commented Jun 24, 2023

https://gitlab.com/Df458/cartographer + https://gitlab.com/Df458/cartographer-mtg create a formspec where a background9[] element has a negative Y size. This results in sh=-1.000 and invalid texture dimensions in imageScaleNNAA which then locks up Minetest.

0x0000555555713275 in imageScaleNNAA (src=src@entry=0x55555687d140, srcrect=..., dest=dest@entry=0x555556879ec0) at minetest/src/client/imagefilters.cpp:191
191			if (minsx > maxsx)
(gdb) bt
#0  0x0000555555713275 in imageScaleNNAA (src=src@entry=0x55555687d140, srcrect=..., 
    dest=dest@entry=0x555556879ec0)
    at minetest/src/client/imagefilters.cpp:191
#1  0x0000555555706af8 in guiScalingResizeCached (driver=0x555555ed1b40, src=<optimized out>, 
    srcrect=..., destrect=...) at minetest/src/client/guiscalingfilter.cpp:121

This PR now skips invalid sized textures and outputs an error message in case it was not checked previously.

To do

This PR is Ready for Review.

How to test

  1. Enable the GUI scaling filter
minetest.register_chatcommand("fs", {
	func = function(name, param)
		minetest.show_formspec(name, "freeze",
			"size[4,4]" ..
			"background9[2,2;-1,-1;default_cobble.png;false;20]" .. -- problematic
			"background[0,0;-4,-4;default_cobble.png]" -- is OK
		)
	end
})
  1. compare master vs PR

@SmallJoker SmallJoker added Bugfix 🐛 PRs that fix a bug Formspec labels Jun 24, 2023
@sfan5 sfan5 changed the title Formspec: prevent infinite loop caused by negative background9[] size guiScalingFilter: prevent infinite loop caused by negative background9[] size Jun 25, 2023
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@SmallJoker SmallJoker merged commit 078bd95 into minetest:master Jul 7, 2023
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants