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
Check that texture width and height is valid before creating texture #8579
Check that texture width and height is valid before creating texture #8579
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks good, I would suggest adding a line in the docstring to say that the width and height must be > 0. What about set_texture? Do we need to do something for that as well?
uint32_t max_mipmaps = (uint32_t) CheckTableInteger(L, 2, "max_mipmaps", 0); | ||
|
||
if ((width < 1) || (height < 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant parentheses (nitpick)
function test_invalid() | ||
assert_error(function() | ||
resource.create_texture("/test_invalid.texturec", tparams_invalid) | ||
end) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤙
Good point about set_texture. Let me check! |
No, that seems to work. |
Calling
resource.create_texture()
with a width and/or height of zero crashed the engine. This change will check that the width and height are valid and throw a Lua error otherwise.Fixes #8578
PR checklist
Example of a well written PR description:
### Technical changes
Technical changes:
Technical notes: