Repository navigation
Conversation
FT_Raccess_Get_DataOffsets allocated the reference array before checking the offsets argument, and held the reference array while it converted the references to offsets. A null offsets pointer or a resource offset that overflows when added to rdataPos threw NotImplemented with both blocks still allocated. Check the offsets argument next to the count argument, before any allocation, and free both blocks before rethrowing from the offset sum. Return values and the count written before the reference reads are unchanged.
…hrows Add two cases to the Raccess test: a null offsets pointer with a matching tag, and a resource offset that overflows when added to rdataPos. Both must throw NotImplemented and leave the allocation and free counts equal. Before the fix the null offsets case and the overflow case each left their reference array (and, for the overflow, the offset array) allocated.
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
|
|
I am closing this for now. The fix itself looked right, but the new test pins two NotImplemented paths with RequireThrows, which we ask to be dropped, and there has been no push since 6 Nov. Feel free to reopen after dropping those two checks at any time and we will look at it again. |
What
FT_Raccess_Get_DataOffsets(libSceFreeTypeOt/src/Raccess.cpp) allocates a reference table and a result array and then throws throughNotImplemented_nid_no_patchwhen the offset sum overflows or when the caller'soffsetspointer is null. Both throws happened after the allocations, so the buffers were never released.fix(libSceFreeTypeOt): free Raccess buffers when DataOffsets throws: the nulloffsetscheck moves next to the existing nullcountcheck, before any allocation; the loop that sums the data offsets is wrapped so that the result array and the reference table are freed before the exception continues. Return codes and the count write are unchanged (*countis still written where it was; an existing test asserts that after a read error).test(libSceFreeTypeOt): cover Raccess buffer release on DataOffsets throws: two cases inGuestFreeTypeOtRaccess.cpp(a nulloffsetswith a matching tag, and a resource data position that overflows the sum). Each expects the throw and checks that the allocations and frees of the guest allocator balance. The file defines a throwingNotImplemented_nid_no_patchfor the test, asGuestJsonFloatFailure.cppdoes.PR #16121 adds helpers and a new
FT_Raccess_Guessin the same file but does not touch the body ofFT_Raccess_Get_DataOffsets.Tested
Linux, throwaway archive build of this head:
BUILD-EXIT 0, ctestguest_freetype_ot_raccess(targetguest_freetype_ot_raccess_tests) passed, 1 of 1.python3 tools/check_conventions.pyagainst the merge base andgit diff --checkare clean. The new cases were not run against the unfixed code; that they fail without the fix is reasoned from the code (the unfixed paths allocate 2 and free 0). Not run on Windows or macOS.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)