@kas1e You should probably put the full source and your analyzer logs somewhere so we can take a better look. E.g. we don't even know how the structs look like etc.
Result.txt one is which is bugs for sure, search there for "menu.c" , "font.c" and "textojb.c" for those 3 bugs it found. "Potentional errors" as usuall can be all kind of false alarms of course
getStringPixmapFT()/my_draw_bitmap() likely trashes mem when blitting into chunky buffer (data) -> font glyph info/"coords" (bitmap_left) maybe can have values the code does not expect (like negative ones). Because of kerning or whatever. my_draw_bitmap() isn't clipping anything.
@Daniel Yeah, is that one :) We don't have normal billiard games (there some other old one, pure "billard" on os4depot, but it suck heavy, no sound, no music, dated look, etc). This one (foobillard++), is looks good, plays good, and i almost have no needs to worry about endianes (just in one place, where they load raw sound via fread()).
So, want to deal with all this, as game at least works already over gl4es/ogles/warp3d.
@Daniel,Georg
Yeah, we very close ! With that function, when i come to those entries which crashes before, it didn't now, but that what it bring to console:
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 256x32)
=== ignoring my_draw_bitmap which would trash: -1,2 25x23 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
=== ignoring my_draw_bitmap which would trash: -1,0 14x15 (bm 512x32)
That for 4 different places where it crashes before.
And visually, it also start to miss first letters. In some places. See screesnhots:
On first you can see at top of game (no the menu entries itself, but at left top side , pure help-message), there is words "hank you very much" , while should be "Thank you very much". On second one "ypes", but should be "Types". And on third screenshot, this time it miss from menu entry in the world "Yes" first "Y.
When its all buggy , and i just comment out free(textdata) to avoid crashes, all letters are in place (but that of course trash the memory).
@Georg Dunno if it another bug, or related to that trashed memory, but another bug arise in another place : not with free(), but with just accessing to some data via that line:
Visually, it happens when i just choice one of the menu entries (few of them cause that crash). Dunno if it related through, or if it just another different issue with that shit-code ..
Probabaly as accessing is to "*menu" , maybe its again abou trashed heap ?
Through as i understand we just avoid accessing to trashed memory, while some parts of memory still trashed and leaks still there ?
It avoids blitting outside left bounds (and thus trashing memory there) because that's what debug output shows it did (negative coords). So the change causes the bitmap to be allocated bigger (wider) and the blits to be offset to the right so that final blit X position of each glyph (char in string) is always >= 0.
Theoretically (weird fonts/languages/accents?) it could still blit outside right/bottom/top side. So to be 100 % safe you would need to check all sides. ~
[..]
int top_most = 0;
int right_most = 0;
int bottom_most = 0;
[..]
int blitx2 = blitx + blitw - 1;
int blity2 = blity + blith - 1;
if (blitx < left_most) left_most = blitx;
if (blity < top_most) top_most = blity;
if (blitx2 > right_most) right_most = blitx2;
if (blity2 > bottom_most) bottom_most = blity2;
[..]
w = (right_most - left_most) + 1;
h = (bottom_most - top_Most) + 1;