diff options
author | 2023-01-12 19:10:41 -0800 | |
---|---|---|
committer | 2023-01-12 19:10:41 -0800 | |
commit | 766f8ceebc76dd749ba5c104f802c7ebda289db9 (patch) | |
tree | f84ee560938188261f7f5604a65b83aae354a646 /src/bun.js/bindings/JSStringDecoder.cpp | |
parent | c03f7c998dd22689412658177e3a5736ce6b9034 (diff) | |
parent | 32f8cb31be6fb5b0b9aea1c6d4e95d118e8ef816 (diff) | |
download | bun-766f8ceebc76dd749ba5c104f802c7ebda289db9.tar.gz bun-766f8ceebc76dd749ba5c104f802c7ebda289db9.tar.zst bun-766f8ceebc76dd749ba5c104f802c7ebda289db9.zip |
Merge branch 'main' into dylan/github-dependencies
Diffstat (limited to 'src/bun.js/bindings/JSStringDecoder.cpp')
-rw-r--r-- | src/bun.js/bindings/JSStringDecoder.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/bun.js/bindings/JSStringDecoder.cpp b/src/bun.js/bindings/JSStringDecoder.cpp index 66f9cb654..ca79e9e1c 100644 --- a/src/bun.js/bindings/JSStringDecoder.cpp +++ b/src/bun.js/bindings/JSStringDecoder.cpp @@ -206,9 +206,30 @@ JSC::JSValue JSStringDecoder::write(JSC::VM& vm, JSC::JSGlobalObject* globalObje } } -JSC::JSValue JSStringDecoder::end(JSC::VM& vm, JSC::JSGlobalObject* globalObject, uint8_t* bufPtr, uint32_t length) +class ResetScope final { +public: + ResetScope(JSStringDecoder* decoder); + ~ResetScope(); + JSStringDecoder* m_decoder; +}; + +ResetScope::ResetScope(JSStringDecoder* decoder) +{ + m_decoder = decoder; +} + +ResetScope::~ResetScope() +{ + m_decoder->m_lastTotal = 0; + m_decoder->m_lastNeed = 0; + memset(m_decoder->m_lastChar, 0, 4); +} + +JSC::JSValue +JSStringDecoder::end(JSC::VM& vm, JSC::JSGlobalObject* globalObject, uint8_t* bufPtr, uint32_t length) { auto throwScope = DECLARE_THROW_SCOPE(vm); + auto resetScope = ResetScope(this); switch (m_encoding) { case BufferEncodingType::ucs2: case BufferEncodingType::utf16le: { |