[runtime] Add assert for illegal alignment (#4235)

Without that check next assert will wrongly pass e.g. for align=65
This commit is contained in:
Vladimir Ivanov
2020-06-17 11:42:18 +03:00
committed by GitHub
parent d6a4a3832e
commit c49bf71d7c
+2
View File
@@ -52,6 +52,8 @@ void* Kotlin_interop_malloc(KLong size, KInt align) {
if (size > SIZE_MAX) {
return nullptr;
}
RuntimeAssert(align > 0, "Unsupported alignment");
RuntimeAssert((align & (align - 1)) == 0, "Alignment must be power of two");
void* result = konan::calloc_aligned(1, size, align);
if ((reinterpret_cast<uintptr_t>(result) & (align - 1)) != 0) {