Repository navigation
LATX, fix: Release file streams on config and ELF exit paths - #507
Merged
LaurenIsACoder merged 3 commits intoOct 15, 2026
Merged
Conversation
load_conf_file() freed the getline buffer but left the FILE stream open. Close it after the parsing loop so normal EOF, early section break, and read-error exits all release the descriptor. A process opens at most the system and user configuration files. Validation: x86_64-linux-user-latx-config-regression. Signed-off-by: zqz <OrzZzznn@gmail.com>
loadElfFromFile() left the stream returned by fopen() open. It also dereferenced a missing header when parsing failed. Close the stream after LoadAndCheckElfHeader(), return early on parse failure, and clear the stored FILE metadata before publishing the header. Signed-off-by: zqz <OrzZzznn@gmail.com>
find_elf_rpath() returned without closing the stream after stat() or header parsing failed. It also leaked the raw descriptor when fdopen() failed. Close the stream on both error paths and close the raw descriptor when fdopen() fails. Signed-off-by: zqz <OrzZzznn@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 变更说明
Fix file-descriptor leaks in LATX configuration parsing and ELF loading.
The valid parsing and library-loading paths keep their existing behavior and
ordering; file resources are only released after they are no longer needed or
when an error path returns early.
修复 LATX 配置解析和 ELF 加载路径中的文件描述符泄漏。正常配置解析和库加载
行为、查找顺序保持不变,只在资源不再需要或错误路径提前返回时释放文件资源。
5ef3b671load_conf_file(): close the configurationFILEafter theparsing loop so normal EOF, early section break, and read-error exits release
the descriptor. Each process opens at most the system and user config files.
299ea156loadElfFromFile(): close the ELF stream afterLoadAndCheckElfHeader(), returnNULLwhen header parsing fails, and clearthe stored
FILE/fd metadata before returning the header.c4bc33dbfind_elf_rpath(): close the stream onstat()and header-parsefailures, and close the raw descriptor when
fdopen()fails.Validation / 验证
lat-opensource/latmaster7cbdeb8f../latxbuild/build-release.sh: passed.meson test -C build64-tests-nokzt --suite lat-pr-fast --print-errorlogs:43/43passed,0failed.LATX_KZT=1 LATX_AOT=0:/usr/gnemul/lat-x86_64/bin/true: exit status0dlopen("libm.so.6")guest: printed1.000$ORIGIN/libRPATH: printed42git diff --check: passed.Checklist / 检查项
CONTRIBUTING.md. / 我已阅读CONTRIBUTING.md。git commit -s). /每个提交都包含 DCO 签署(
git commit -s)。are not applicable. /
我已提供相关构建或测试结果,或说明了不适用的原因。