Skip to content

Hold on to data used for FT_New_Memory_Face until after FT_Done_Face is called.#19

Merged
bdon merged 1 commit into
maplibre:mainfrom
felt:cloer/hold_memory
Feb 16, 2023
Merged

Hold on to data used for FT_New_Memory_Face until after FT_Done_Face is called.#19
bdon merged 1 commit into
maplibre:mainfrom
felt:cloer/hold_memory

Conversation

@ChrisLoer
Copy link
Copy Markdown
Collaborator

FreeType documentation for FT_New_Memory_face at https://freetype.org/freetype2/docs/reference/ft2-base_interface.html specifies "You must not deallocate the memory before calling FT_Done_Face", but it looks like we pass it a pointer to the contents of a vector that goes out of scope. This change just does a simple char* malloc and holds onto it until free_fontstack.

I came across this while debugging missing/corrupted glyphs showing up in a large set of SDFs. To my surprise, the missing glyphs showed up when I ran font-maker a second time with the same inputs, and then when I put some debugging code in to capture the set of glyphs, I found that the set of glyphs changed from one run to the next.

Looking at the code, I saw this, it looked suspicious, and when I changed it the set of glyphs started being reproducible between runs. I haven't done much else to verify the change (didn't actually observe memory corruption in the debugger or anything), but it seems pretty straightforward, at least if I'm reading the docs right.

@bdon

@bdon bdon merged commit 2584db2 into maplibre:main Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants