[libc-commits] [libc] [libc] Fix memory leak in linux/file.cpp (PR #150801)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Jul 28 13:58:54 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);
----------------
michaelrj-google wrote:

I'm fine with doing that cleanup, but I am also planning on doing a rewrite of FILE in the not too distant future.

https://github.com/llvm/llvm-project/pull/150801


More information about the libc-commits mailing list