From b4fc3fcc8cb9bdb5af9d894c33185d00cebe9080 Mon Sep 17 00:00:00 2001 From: cybran Date: Sun, 8 Oct 2023 18:00:34 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Utf8Value=20?= =?UTF-8?q?=E5=80=BC=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deps/miniv8/src/MiniV8Api.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deps/miniv8/src/MiniV8Api.cpp b/deps/miniv8/src/MiniV8Api.cpp index 8c00d434..ccfdd489 100644 --- a/deps/miniv8/src/MiniV8Api.cpp +++ b/deps/miniv8/src/MiniV8Api.cpp @@ -1848,13 +1848,16 @@ v8::String::Utf8Value::Utf8Value(v8::Local str) miniv8::V8String* v8string = v8::Utils::openHandle(*(str.As())); const std::string& strv8 = v8string->getStr(); - this->str_ = (char*)strv8.c_str(); this->length_ = (int)strv8.size(); + this->str_ = new char[this->length_ + 1]; + std::strncpy(this->str_, strv8.c_str(), this->length_ + 1); + this->str_[this->length_] = '\0'; } v8::String::Utf8Value::~Utf8Value(void) { printEmptyFuncInfo(__FUNCTION__, false, false); + delete[] str_; } #if V8_MINOR_VERSION < 8 -- Gitee