Skip to content

fix(libSceFreeTypeOt): release references when result allocation throws - #2111

Open
Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/28337
Open

Thimo188 wants to merge 1 commit into
mainfrom
upstream-pr/28337

Conversation

@Thimo188

@Thimo188 Thimo188 commented Dec 2, 2026 •

Copy link
Copy Markdown
Owner

Imported from boykopovar/AnyPS5#28337, originally opened by aarushvan.

Source commit: 828f6f5f3643bed03aecbf2670b5c4019cbeb38c. The import branch preserves this fetched upstream PR snapshot. The description and validation below are copied from upstream; no new code changes or test runs were made for this import. Original reviews, discussions, and attachments remain at the linked upstream PR.


What

Release the allocated reference table (OtMemFree(memory, ref)) if OtMemRealloc throws while allocating the result array in FT_Raccess_Get_DataOffsets_nid_postfix, then rethrow the original exception. Distinct from open PR #16367, which moves the null offsets check and catches exceptions in the post-allocation Add() loop but does not free ref if OtMemRealloc itself throws.

Tested

macOS arm64, Apple Clang, production libSceFreeTypeOt raccess component (Raccess.cpp, Memory.cpp, Stream.cpp). The regression test in GuestFreeTypeOtRaccess.cpp fails against unmodified main (FreeType Ot raccess: offset allocation failure frees the reference table) and passes with the fix (Guest FreeType Ot raccess tests passed), verifying both null-returning and throwing result allocation paths leave caller outputs untouched and free the reference array. tools/check_conventions.py, tools/debt_fold.py --check, and git diff --check passed. Full CMake build, runtime, and console testing remain outstanding.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt and the licence notice of code adapted from upstream (see AGENTS.md)
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: fix(libSceFreeTypeOt): free Raccess buffers when FT_Raccess_Get_DataOffsets throws boykopovar/AnyPS5#16367
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when font-related data allocation fails. Resources created earlier in the operation are now released, and allocation errors are handled without publishing incomplete results. This helps prevent resource leaks and keeps failure behavior consistent across allocation failure scenarios.

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Raccess allocation cleanup

Layer / File(s) Summary
Offset allocation failure handling
core/libs/prx/libSceFreeTypeOt/src/Raccess.cpp, core/libs/tests/GuestFreeTypeOtRaccess.cpp, docs/dev/debt/changes/fix-freetype-raccess-allocation-exception.md
The allocation path frees the resource-reference array if OtMemRealloc throws. Tests check exception propagation, the 0x40 error for a null return, unchanged caller outputs, and cleanup. The debt entry notes that console behavior is unverified when the guest result allocator or release callback throws.

Suggested reviewers: domx4q, noamroger

Change: Bug fix

Merge Risk: Minimal · up to 828f6

The change fixes a leak of the reference table when the guest allocator throws while FreeType resource offsets are being read. Tests cover both the throwing and null-returning allocator paths. No concrete merge-blocking risk was found. A full build and console testing are still pending.

Security architecture risk: Minimal · up to 828f6

libSceFreeTypeOt now releases its temporary reference table if allocating the result offsets throws. It uses the same allocator record as the existing cleanup paths and leaves successful calls and ordinary allocation-error returns unchanged.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

  • Mode: Continue automatically
  • Reviewed files: 3
  • Waived: $0.75 (charged $0.00)
  • View usage details

Note

This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dda02351-490e-4aad-bdf1-dd8cb37afa5d
Commits

Reviewing files that changed from the base of the PR and between 4131f51 and 828f6f5.

Files selected for processing: 3

  • core/libs/prx/libSceFreeTypeOt/src/Raccess.cpp
  • core/libs/tests/GuestFreeTypeOtRaccess.cpp
  • docs/dev/debt/changes/fix-freetype-raccess-allocation-exception.md

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