Skip to content

Minor FFI hardening fixes#443

Open
kinetiknz wants to merge 7 commits intomasterfrom
get_indice_table
Open

Minor FFI hardening fixes#443
kinetiknz wants to merge 7 commits intomasterfrom
get_indice_table

Conversation

@kinetiknz
Copy link
Collaborator

@kinetiknz kinetiknz commented Mar 13, 2026

Tiny defensive changes:

  • avoid exposing invalid heap pointers to FFI if the cache insert fails. The caller would've still received an error and should not expect the pointers to be valid, but it's better to avoid exposing them in this error case.
  • init avif_info and avif_image with defaults to match other code and avoid exposing uninitialized structs on error paths
  • make sample_info conversion failure explicit rather than silent
  • add missing nullptr checks in some FFI functions
  • avoid truncating timescale silently
  • add an assert to catch read callback misbehaviour

Tiny defensive change: avoids exposing invalid heap pointers to FFI if
the cache insert fails.  The caller would've still received an error and
should not expect the pointers to be valid, but it's better to avoid
exposing them in this error case.
@kinetiknz kinetiknz requested review from ashleyz and padenot March 13, 2026 20:44
@kinetiknz kinetiknz self-assigned this Mar 13, 2026
…ary.

QuickTime v2 audio sample entries can carry a u32 channel count and
f64 sample rate that don't fit the u16/u32 C-API fields. Replace the
silent truncating casts with checked conversions that return Invalid.
…mented.

Both functions dereferenced their out-pointer without first checking
for null, unlike every other C API entry point. Add the missing guards
so callers that pass null get BadArg instead of a null-deref.
@kinetiknz kinetiknz changed the title ffi: Perform cache insert before initializing indices. Minor FFI hardening fixes Mar 13, 2026
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.

1 participant