[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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user