Skip to content

Commit 78097f9

Browse files
committed
Fix building on API level 26
the aligned_alloc function was not introduced to Android's C library (Bionic) until API level 28.
1 parent 015e733 commit 78097f9

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

test/cctest/test_crypto_clienthello.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ class OverrunGuardedBuffer {
5454
#ifdef USE_MPROTECT
5555
// Place the packet right before a guard page, which, when accessed, causes
5656
// a segmentation fault.
57+
#if defined(__ANDROID__) && __ANDROID_API__ < 28
58+
void* ptr = nullptr;
59+
if (posix_memalign(&ptr, page, 2 * page) != 0) {
60+
ptr = nullptr; // Handle allocation failure if necessary
61+
}
62+
alloc_base = static_cast<uint8_t*>(ptr);
63+
#else
5764
alloc_base = static_cast<uint8_t*>(aligned_alloc(page, 2 * page));
65+
#endif
5866
CHECK_NOT_NULL(alloc_base);
5967
uint8_t* second_page = alloc_base + page;
6068
CHECK_EQ(mprotect(second_page, page, PROT_NONE), 0);

0 commit comments

Comments
 (0)