Don't assign "" to elems as it can later get free()d invalidly

This commit is contained in:
baldurk
2014-08-13 09:32:53 +01:00
parent ff371ee768
commit dcbba16af5
2 changed files with 12 additions and 6 deletions
+8 -4
View File
@@ -33,7 +33,8 @@ wstr &wstr::operator =(const std::wstring &in)
count = (int32_t)in.size();
if(count == 0)
{
elems = L"";
elems = (wchar_t*)allocate(1);
elems[0] = 0;
}
else
{
@@ -50,7 +51,8 @@ str &str::operator =(const std::string &in)
count = (int32_t)in.size();
if(count == 0)
{
elems = "";
elems = (char*)allocate(1);
elems[0] = 0;
}
else
{
@@ -67,7 +69,8 @@ wstr &wstr::operator =(const wchar_t *const in)
count = (int32_t)wcslen(in);
if(count == 0)
{
elems = L"";
elems = (wchar_t*)allocate(1);
elems[0] = 0;
}
else
{
@@ -84,7 +87,8 @@ str &str::operator =(const char *const in)
count = (int32_t)strlen(in);
if(count == 0)
{
elems = "";
elems = (char*)allocate(1);
elems[0] = 0;
}
else
{
+4 -2
View File
@@ -124,7 +124,8 @@ struct str : public rdctype::array<char>
count = o.count;
if(count == 0)
{
elems = "";
elems = (char*)allocate(1);
elems[0] = 0;
}
else
{
@@ -153,7 +154,8 @@ struct wstr : public rdctype::array<wchar_t>
count = o.count;
if(count == 0)
{
elems = L"";
elems = (wchar_t*)allocate(1);
elems[0] = 0;
}
else
{