Removed an unnecessary string allocation during copying.
This commit is contained in:
@@ -221,9 +221,8 @@ copy_string (const char * s)
|
|||||||
// FIXME: potential buffer overflow.
|
// FIXME: potential buffer overflow.
|
||||||
// For some reason, strnlen and
|
// For some reason, strnlen and
|
||||||
// strncpy cause all kinds of crashes.
|
// strncpy cause all kinds of crashes.
|
||||||
string str = s;
|
char * copy = new char[strlen(s) + 1];
|
||||||
char * copy = new char[str.size() + 1];
|
strcpy(copy, s);
|
||||||
strcpy(copy, str.c_str());
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user