Fixing some undefined behaviour, Issue 2277

This commit is contained in:
Ingo
2014-03-11 11:49:06 +01:00
parent 64562bd83f
commit aeeaf4de3c
14 changed files with 55 additions and 34 deletions

View File

@@ -371,8 +371,10 @@ class UserCommentInterpreter : public Interpreter {
UserCommentInterpreter () {}
virtual std::string toString (Tag* t) {
char *buffer = new char[t->getCount()];
if (!strncmp((char*)t->getValue(), "ASCII\0\0\0",8))
if (!strncmp((char*)t->getValue(), "ASCII\0\0\0",8)) {
strncpy (buffer, (char*)t->getValue()+8, t->getCount()-8);
buffer[t->getCount()-8] = '\0';
}
else
buffer[0]=0;
std::string retVal(buffer);