[libcxx-commits] [libcxx] [libc++][hardening] Classify assertions related to leaks and syscalls. (PR #77164)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 9 13:02:26 PST 2024
================
@@ -668,7 +668,9 @@ path __read_symlink(const path& p, error_code* ec) {
detail::SSizeT ret;
if ((ret = detail::readlink(p.c_str(), buff.get(), size)) == -1)
return err.report(capture_errno());
- _LIBCPP_ASSERT_UNCATEGORIZED(ret > 0, "TODO");
+ // `ret` indicates the number of bytes written to the buffer, `0` means that the attempt to read the symlink produced
+ // an empty string.
+ _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(ret > 0, "TODO");
----------------
ldionne wrote:
The only case to consider here is if `ret == 0`, and I think in that case the code should "work fine". We'll return a buffer of size at least 1, and where `buf[0] == '\0'`. That's weird but valid. In that line of thought, I think this assertion is wrong (or at least it's in the wrong place).
https://github.com/llvm/llvm-project/pull/77164
More information about the libcxx-commits
mailing list