diff options
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/WasmObjectFile.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp index 4d4c887b2d9..1b32ae8afd9 100644 --- a/llvm/lib/Object/WasmObjectFile.cpp +++ b/llvm/lib/Object/WasmObjectFile.cpp @@ -216,9 +216,16 @@ static Error readSection(WasmSection &Section, return make_error<StringError>("Section too large", object_error::parse_failed); if (Section.Type == wasm::WASM_SEC_CUSTOM) { - const uint8_t *NameStart = Ctx.Ptr; - Section.Name = readString(Ctx); - Size -= Ctx.Ptr - NameStart; + WasmObjectFile::ReadContext SectionCtx; + SectionCtx.Start = Ctx.Ptr; + SectionCtx.Ptr = Ctx.Ptr; + SectionCtx.End = Ctx.Ptr + Size; + + Section.Name = readString(SectionCtx); + + uint32_t SectionNameSize = SectionCtx.Ptr - SectionCtx.Start; + Ctx.Ptr += SectionNameSize; + Size -= SectionNameSize; } Section.Content = ArrayRef<uint8_t>(Ctx.Ptr, Size); Ctx.Ptr += Size; |