[libcxx-commits] [PATCH] D91140: [8/N] [libcxx] Fix the preexisting directory_iterator code for windows

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 14 15:35:47 PST 2020


ldionne requested changes to this revision.
ldionne added inline comments.
This revision now requires changes to proceed.


================
Comment at: libcxx/src/filesystem/directory_iterator.cpp:75
 }
 #else
 
----------------
I think adding a comment here to signify that this is the Windows branch would add readability.


================
Comment at: libcxx/src/filesystem/directory_iterator.cpp:121
+    }
+    __stream_ = ::FindFirstFileW((root / "*").c_str(), &__data_);
     if (__stream_ == INVALID_HANDLE_VALUE) {
----------------
Isn't that a use-after-free? `(root / "*").c_str()` returns a pointer to the internal string held in the temporary object created by `(root / "*")`, unless I'm missing a subtlety here. I don't think the lifetime of objects in an expression used as a function argument is extended automatically.


================
Comment at: libcxx/src/filesystem/filesystem_common.h:21
+#if !defined(_LIBCPP_WIN32API)
 #include <unistd.h>
 #include <sys/stat.h>
----------------
Please indent `#include`s in between.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91140/new/

https://reviews.llvm.org/D91140



More information about the libcxx-commits mailing list