diff --git a/base/file_utils.cc b/base/file_utils.cc index 7173000..ba8957c 100644 --- a/base/file_utils.cc +++ b/base/file_utils.cc @@ -144,10 +144,14 @@ file_utils::get_file_length(string const &file) { void file_utils::zero_superblock(std::string const &path) { + char *buffer; unsigned const SUPERBLOCK_SIZE = 4096; - char buffer[SUPERBLOCK_SIZE]; int fd = open_block_file(path, SUPERBLOCK_SIZE, true, true); + buffer = reinterpret_cast(aligned_alloc(SUPERBLOCK_SIZE, SUPERBLOCK_SIZE)); + if (!buffer) + throw runtime_error("out of memory"); + memset(buffer, 0, SUPERBLOCK_SIZE); if (::write(fd, buffer, SUPERBLOCK_SIZE) != SUPERBLOCK_SIZE) throw runtime_error("couldn't zero superblock");