diff --git a/include/internal/cef_string_wrappers.h b/include/internal/cef_string_wrappers.h index 06fc42697..aa587c8e1 100644 --- a/include/internal/cef_string_wrappers.h +++ b/include/internal/cef_string_wrappers.h @@ -411,7 +411,7 @@ public: /// void clear() { - if (!empty()) + if (string_) traits::clear(string_); } diff --git a/libcef/v8_impl.cc b/libcef/v8_impl.cc index 5b4009574..d265b850e 100644 --- a/libcef/v8_impl.cc +++ b/libcef/v8_impl.cc @@ -138,6 +138,8 @@ void GetCefString(v8::Handle str, CefString& out) #if defined(CEF_STRING_TYPE_WIDE) // Allocate enough space for a worst-case conversion. int len = str->Utf8Length(); + if (len == 0) + return; char* buf = new char[len + 1]; str->WriteUtf8(buf, len + 1); @@ -149,11 +151,15 @@ void GetCefString(v8::Handle str, CefString& out) #else // !defined(CEF_STRING_TYPE_WIDE) #if defined(CEF_STRING_TYPE_UTF16) int len = str->Length(); + if (len == 0) + return; char16* buf = new char16[len + 1]; str->Write(reinterpret_cast(buf), 0, len + 1); #else // Allocate enough space for a worst-case conversion. int len = str->Utf8Length(); + if (len == 0) + return; char* buf = new char[len + 1]; str->WriteUtf8(buf, len + 1); #endif