pxt-arcade
pxt-arcade copied to clipboard
image create crashes browser if parameter is not integer
Describe the bug
image create crashes browser if parameter is a double
To Reproduce Steps to reproduce the behavior:
- Go to https://makecode.com/_XHAFjcRy1Mgf
- See error
Expected behavior
should not crash browser, probably just needs a pair of | 0
's on the params in https://github.com/microsoft/pxt-common-packages/blob/master/libs/screen/sim/image.ts#L14 / maybe hw side as well
worth noting that this looks like it's just when wh does not make an integer (e.g. here it's 1.5 * 1.5) -- here with 1.52 works without crashing https://makecode.com/_iVu317FgYh8w, so maybe core issue is something like the buffer allocation logic having an equals check instead of a comparison or something?
maybe also worth just returning undefined instead of crashing when w / h is negative, but I would expect something to die in that case eventually anyways