Fix #4265: "Segfault saving image with edited metadata"
This commit is contained in:
@@ -1938,17 +1938,15 @@ void Tag::initUserComment (const Glib::ustring &text)
|
|||||||
count = 8 + strlen (text.c_str());
|
count = 8 + strlen (text.c_str());
|
||||||
valuesize = count;
|
valuesize = count;
|
||||||
value = new unsigned char[valuesize];
|
value = new unsigned char[valuesize];
|
||||||
strcpy ((char*)value, "ASCII");
|
memcpy((char*)value, "ASCII\0\0\0", 8);
|
||||||
value[5] = value[6] = value[7] = 0;
|
memcpy((char*)value + 8, text.c_str(), valuesize - 8);
|
||||||
strcpy ((char*)value + 8, text.c_str());
|
|
||||||
} else {
|
} else {
|
||||||
wchar_t *commentStr = (wchar_t*)g_utf8_to_utf16 (text.c_str(), -1, NULL, NULL, NULL);
|
wchar_t *commentStr = (wchar_t*)g_utf8_to_utf16 (text.c_str(), -1, NULL, NULL, NULL);
|
||||||
count = 8 + wcslen(commentStr)*2;
|
count = 8 + wcslen(commentStr)*2;
|
||||||
valuesize = count;
|
valuesize = count;
|
||||||
value = (unsigned char*)new char[valuesize];
|
value = (unsigned char*)new char[valuesize];
|
||||||
strcpy ((char*)value, "UNICODE");
|
memcpy((char*)value, "UNICODE\0", 8);
|
||||||
value[7] = 0;
|
memcpy((char*)value + 8, (char*)commentStr, valuesize - 8);
|
||||||
wcscpy(((wchar_t*)value) + 4, commentStr);
|
|
||||||
g_free(commentStr);
|
g_free(commentStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user