Skip to content

Commit

Permalink
[CritFix] Deserialise hyperscan to the page-aligned space to prevent …
Browse files Browse the repository at this point in the history
…alignment issues

Issue: #4329
  • Loading branch information
vstakhov committed Nov 11, 2022
1 parent b9b54ac commit 068714f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libserver/hyperscan_tools.cxx
Expand Up @@ -306,7 +306,15 @@ auto load_cached_hs_file(const char *fname, std::int64_t offset = 0) -> tl::expe
msg_debug_hyperscan_lambda("multipattern: create new database in %s; %Hz size",
tmpfile_pattern.data(), unserialized_size);
void *buf;
posix_memalign(&buf, 16, unserialized_size);
#ifdef HAVE_GETPAGESIZE
auto page_size = getpagesize();
#else
auto page_size = sysconf(_SC_PAGESIZE);
#endif
if (page_size == -1) {
page_size = 4096;
}
posix_memalign(&buf, page_size, unserialized_size);
if (buf == nullptr) {
return tl::make_unexpected(error {"Cannot allocate memory", errno, error_category::CRITICAL });
}
Expand Down

0 comments on commit 068714f

Please sign in to comment.