PathOfBuildingCommunity / PathOfBuilding-SimpleGraphic

Other
7 stars 21 forks source link

Read font info files incrementally #21

Closed zao closed 3 years ago

zao commented 3 years ago

The previous text-mode reading had a problem where the extractable character count of a file opened in non-binary (text) mode is subject to the actual contents of the file due to newline translation and EOF characters, and can only be determined by actually scanning over the content.

GetLen yields the binary size of the file and thus tends to overallocate the buffer, leading to the actual read attempting to read more data than can actually be extracted. This puts the code at the mercy of what garbage the target string contains from the allocator and how much data could actually be read.