Merge revision 603 changes:
- Fix memory leak when returning zero-length strings from V8 (issue #581). git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/963@605 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
1707bb75e5
commit
c5e4fef620
|
@ -411,7 +411,7 @@ public:
|
||||||
///
|
///
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
if (!empty())
|
if (string_)
|
||||||
traits::clear(string_);
|
traits::clear(string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,6 +138,8 @@ void GetCefString(v8::Handle<v8::String> str, CefString& out)
|
||||||
#if defined(CEF_STRING_TYPE_WIDE)
|
#if defined(CEF_STRING_TYPE_WIDE)
|
||||||
// Allocate enough space for a worst-case conversion.
|
// Allocate enough space for a worst-case conversion.
|
||||||
int len = str->Utf8Length();
|
int len = str->Utf8Length();
|
||||||
|
if (len == 0)
|
||||||
|
return;
|
||||||
char* buf = new char[len + 1];
|
char* buf = new char[len + 1];
|
||||||
str->WriteUtf8(buf, len + 1);
|
str->WriteUtf8(buf, len + 1);
|
||||||
|
|
||||||
|
@ -149,11 +151,15 @@ void GetCefString(v8::Handle<v8::String> str, CefString& out)
|
||||||
#else // !defined(CEF_STRING_TYPE_WIDE)
|
#else // !defined(CEF_STRING_TYPE_WIDE)
|
||||||
#if defined(CEF_STRING_TYPE_UTF16)
|
#if defined(CEF_STRING_TYPE_UTF16)
|
||||||
int len = str->Length();
|
int len = str->Length();
|
||||||
|
if (len == 0)
|
||||||
|
return;
|
||||||
char16* buf = new char16[len + 1];
|
char16* buf = new char16[len + 1];
|
||||||
str->Write(reinterpret_cast<uint16_t*>(buf), 0, len + 1);
|
str->Write(reinterpret_cast<uint16_t*>(buf), 0, len + 1);
|
||||||
#else
|
#else
|
||||||
// Allocate enough space for a worst-case conversion.
|
// Allocate enough space for a worst-case conversion.
|
||||||
int len = str->Utf8Length();
|
int len = str->Utf8Length();
|
||||||
|
if (len == 0)
|
||||||
|
return;
|
||||||
char* buf = new char[len + 1];
|
char* buf = new char[len + 1];
|
||||||
str->WriteUtf8(buf, len + 1);
|
str->WriteUtf8(buf, len + 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue