std: Don't trust stat() size in readAllAlloc fns

Some files such as the ones in /proc report a st_size of zero, try to
read the file anyway if we hit that case.
This commit is contained in:
LemonBoy
2020-09-01 18:48:43 +02:00
parent 26140678a5
commit 73a8c9beaa
5 changed files with 28 additions and 17 deletions

View File

@@ -1454,9 +1454,7 @@ pub const Dir = struct {
var file = try self.openFile(file_path, .{});
defer file.close();
const stat_size = try file.getEndPos();
return file.readAllAllocOptions(allocator, stat_size, max_bytes, alignment, optional_sentinel);
return file.readAllAllocOptions(allocator, max_bytes, alignment, optional_sentinel);
}
pub const DeleteTreeError = error{