diff --git a/repos/ports/src/lib/libc_noux/plugin.cc b/repos/ports/src/lib/libc_noux/plugin.cc index d0cf513dda..72e0971d16 100644 --- a/repos/ports/src/lib/libc_noux/plugin.cc +++ b/repos/ports/src/lib/libc_noux/plugin.cc @@ -1242,8 +1242,10 @@ namespace { Libc::Plugin_context *context = noux_context(sysio()->open_out.fd); Libc::File_descriptor *fd = Libc::file_descriptor_allocator()->alloc(this, context, sysio()->open_out.fd); - if ((flags & O_TRUNC) && (ftruncate(fd, 0) == -1)) + if ((flags & O_TRUNC) && (ftruncate(fd, 0) == -1)) { + Plugin::close(fd); return 0; + } return fd; }