-
Notifications
You must be signed in to change notification settings - Fork 101
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
TLN_SetRenderTarget with a larger pitch causes heap buffer overflow (segfault) #126
Comments
uint8_t framebuffer[240 * 160 * 4];
TLN_Init(240, 160, 4, 128, 0);
TLN_SetRenderTarget(framebuffer, 240 * 4); BTW, texture width is not required to be power of 2 |
It could be required on certain GPU architectures. The point is, it sometimes makes sense to want to have Tilengine draw each row of pixels with a "pitch" (also called "stride") of some specific alignment for various reasons, otherwise the user may have to memmove/memcpy each row to fix that. Is the pitch argument not intended for this purpose? I mean, if it is supposed to be |
There isn't any problem in setting a pitch bigger that the required by the framebuffer (for example, setting 320x240 inside a texture of 512x256). Just make sure you're allocating the framebuffer correctly with required memory. I've tested right now and it works as expected. |
Please test with ASan ( Looking at the code:
|
For example, if we do the following:
Then when calling
TLN_UpdateFrame
we get a heap buffer overflow at:Tilengine/src/Draw.c
Line 173 in d4f8737
The buffer is allocated at:
Tilengine/src/Tilengine.c
Line 106 in d4f8737
The text was updated successfully, but these errors were encountered: