mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-16 17:22:21 +00:00
Fixes misaligned pointer by reading from the buffer instead of loading the memory separately (#8649)
This commit is contained in:
@@ -120,6 +120,22 @@ final class FlatBuffersTests: XCTestCase {
|
||||
XCTAssertEqual(scalarTable.justEnum, .one)
|
||||
XCTAssertNil(scalarTable.maybeEnum)
|
||||
}
|
||||
|
||||
func testAlignmentCrash() {
|
||||
var builder = FlatBufferBuilder(initialSize: 256)
|
||||
|
||||
// Create two identical tables to trigger vtable deduplication
|
||||
let str1 = builder.create(string: "test")
|
||||
let start1 = builder.startTable(with: 1)
|
||||
builder.add(offset: str1, at: 0)
|
||||
_ = builder.endTable(at: start1)
|
||||
|
||||
// Second table triggers vtable comparison where crash occurs
|
||||
let str2 = builder.create(string: "crash")
|
||||
let start2 = builder.startTable(with: 1)
|
||||
builder.add(offset: str2, at: 0)
|
||||
_ = builder.endTable(at: start2) // ← Crashes here on ARM64
|
||||
}
|
||||
}
|
||||
|
||||
class Country {
|
||||
|
||||
Reference in New Issue
Block a user