Fix memory leak in d2charsave_init_from_d2s()
This commit is contained in:
parent
4ca4e6b971
commit
3f892f03c2
1 changed files with 2 additions and 2 deletions
|
@ -80,8 +80,8 @@ namespace pvpgn
|
|||
bn_short_set((bn_short *)((char *)buffer + D2CHARSAVE_STATUS_OFFSET_109), status);
|
||||
|
||||
// charname
|
||||
std::strncpy((char *)buffer + D2CHARSAVE_CHARNAME_OFFSET_109, new char[MAX_CHARNAME_LEN], MAX_CHARNAME_LEN); // clear first
|
||||
std::strncpy((char *)buffer + D2CHARSAVE_CHARNAME_OFFSET_109, charname, MAX_CHARNAME_LEN);
|
||||
std::memset(buffer + D2CHARSAVE_CHARNAME_OFFSET_109, '\0', MAX_CHARNAME_LEN); // clear first
|
||||
std::strncpy((char *)buffer + D2CHARSAVE_CHARNAME_OFFSET_109, charname, MAX_CHARNAME_LEN);
|
||||
|
||||
// checksum
|
||||
checksum = d2charsave_checksum((unsigned char *)buffer, size, D2CHARSAVE_CHECKSUM_OFFSET);
|
||||
|
|
Loading…
Reference in a new issue