Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when resize size of ArrayBuffer from zero #1353

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/runtime/ArrayBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ class ArrayBufferView : public DerivedObject {
return true;
}

virtual size_t elementSize()
{
return 1;
}

void* operator new(size_t size)
{
static MAY_THREAD_LOCAL bool typeInited = false;
Expand Down Expand Up @@ -225,9 +230,9 @@ class ArrayBufferView : public DerivedObject {
self->m_arrayLength = self->m_byteLength = self->m_byteOffset = 0;
} else if (self->m_auto) {
// auto mode within boundary
size_t elementSize = self->m_arrayLength ? self->m_byteLength / self->m_arrayLength : SIZE_MAX;
self->m_byteLength = newByteLength - self->m_byteOffset;
self->m_arrayLength = elementSize == SIZE_MAX ? 0 : self->m_byteLength / elementSize;
ASSERT(self->elementSize());
self->m_arrayLength = self->m_byteLength / self->elementSize();
}

self->updateCachedAddress(newAddress);
Expand Down
5 changes: 0 additions & 5 deletions src/runtime/TypedArrayObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ class TypedArrayObject : public ArrayBufferView {
RELEASE_ASSERT_NOT_REACHED();
}

virtual size_t elementSize()
{
RELEASE_ASSERT_NOT_REACHED();
}

virtual String* typedArrayName(ExecutionState& state)
{
RELEASE_ASSERT_NOT_REACHED();
Expand Down
2 changes: 1 addition & 1 deletion test/vendortest
Loading