[libc-commits] [libc] [libc] Fix memory leak in linux/file.cpp (PR #150801)
via libc-commits
libc-commits at lists.llvm.org
Sat Jul 26 19:20:35 PDT 2025
================
@@ -165,6 +165,7 @@ ErrorOr<LinuxFile *> create_file_from_fd(int fd, const char *mode) {
auto *file = new (ac)
LinuxFile(fd, buffer, File::DEFAULT_BUFFER_SIZE, _IOFBF, true, modeflags);
if (!ac) {
+ free(buffer);
----------------
lntue wrote:
There are other places in this file having similar issue. We should create a Buffer class wrapper to make sure it is cleanup properly with RAII.
https://github.com/llvm/llvm-project/pull/150801
More information about the libc-commits
mailing list