Commit 1fe435a
committed
bsv, cdfs: free intfstream_t after intfstream_close at five remaining leak sites
Audit pass over every intfstream_close call site in production
code: out of 53 sites, 48 were already followed by free() (the
established libretro-common convention -- intfstream_close
closes the inner backend, the caller owns the struct). Five
were not, leaking 48 bytes per call.
Five fixed:
- input/bsv/bsvmovie.c:1315 check_stream (open_memory)
- input/bsv/bsvmovie.c:1643 out_stream (open_writable_memory)
- input/bsv/bsvmovie.c:1845 read_mem (open_memory)
- libretro-common/formats/cdfs/cdfs.c:433 cue_stream (alloc-fail path)
- libretro-common/formats/cdfs/cdfs.c:438 cue_stream (success path)
The bsv leaks are the more interesting set: those code paths
run on every replay verification (check_stream), every
checkpoint encode (out_stream), and every checkpoint decode
(read_mem) -- so during a long netplay session with an active
replay or in checkpointed playback the leak compounds linearly
with elapsed time. Each instance is small (48 bytes per
intfstream_t struct) but they accumulate.
The cdfs leak is per-cue-file: every time RetroArch parses a
.cue (loading a multi-track CD image, bulk database scan over
a CD library) it leaks 48 bytes. Both close paths in
cdfs_open_cue_path were affected.
Note on contract: changing intfstream_close to free the struct
itself was considered and rejected. intfstream_close ships in
libretro-common which is vendored into many cores; cores that
correctly compensate for the existing convention by calling
free() after close (the same pattern this commit standardises
on inside RetroArch itself) would silently double-free under a
contract change. Fix-the-call-sites is the only safe path.
The 48 already-correct call sites are left as-is. This commit
is a pure addition of missing free() calls; no behavioural or
cleanup-order changes.1 parent bac6894 commit 1fe435a
2 files changed
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1313 | 1313 | | |
1314 | 1314 | | |
1315 | 1315 | | |
| 1316 | + | |
1316 | 1317 | | |
1317 | 1318 | | |
1318 | 1319 | | |
| |||
1641 | 1642 | | |
1642 | 1643 | | |
1643 | 1644 | | |
| 1645 | + | |
1644 | 1646 | | |
1645 | 1647 | | |
1646 | 1648 | | |
| |||
1843 | 1845 | | |
1844 | 1846 | | |
1845 | 1847 | | |
| 1848 | + | |
1846 | 1849 | | |
1847 | 1850 | | |
1848 | 1851 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
| 434 | + | |
434 | 435 | | |
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
| 440 | + | |
439 | 441 | | |
440 | 442 | | |
441 | 443 | | |
| |||
0 commit comments