Skip to content
Closed
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
16 changes: 8 additions & 8 deletions src/node_i18n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,13 @@ class ConverterObject : public BaseObject, Converter {
result.AllocateSufficientStorage(limit);

UBool flush = (flags & CONVERTER_FLAGS_FLUSH) == CONVERTER_FLAGS_FLUSH;
OnScopeLeave cleanup([&]() {
if (flush) {
// Reset the converter state.
converter->bomSeen_ = false;
ucnv_reset(converter->conv);
}
});

const char* source = input_obj_data;
size_t source_length = input_obj_length;
Expand All @@ -238,17 +245,10 @@ class ConverterObject : public BaseObject, Converter {
result.SetLength(target - &result[0]);
ret = ToBufferEndian(env, &result);
args.GetReturnValue().Set(ret.ToLocalChecked());
goto reset;
return;
}

args.GetReturnValue().Set(status);

reset:
if (flush) {
// Reset the converter state
converter->bomSeen_ = false;
ucnv_reset(converter->conv);
}
}

void MemoryInfo(MemoryTracker* tracker) const override {
Expand Down