mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:00:11 +01:00
Fix ReadlinkSlow buffer when lstat reports zero size (#6948)
When the symlink target length from lstat was 0, the code resized the buffer using status.size() instead of buffer_size, so the first allocation stayed empty instead of using MinBufferSize. Align the resize with the buffer_size path used for readlinkat.
This commit is contained in:
@@ -643,7 +643,7 @@ auto DirRef::ReadlinkSlow(const std::filesystem::path& path)
|
||||
if (buffer_size == 0) {
|
||||
buffer_size = MinBufferSize;
|
||||
}
|
||||
large_buffer.resize(status.size());
|
||||
large_buffer.resize(buffer_size);
|
||||
ssize_t result =
|
||||
readlinkat(dfd_, path.c_str(), large_buffer.data(), large_buffer.size());
|
||||
if (result == -1) {
|
||||
|
||||
Reference in New Issue
Block a user