-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Description
template<typename T>
inline void Serializer::output_type(T& t)
{
int len = sizeof(T);
char* d = new char[len];
if (!m_iodevice.is_eof()){
memcpy(d, m_iodevice.current(), len);
m_iodevice.offset(len);
byte_orser(d, len);
t = *reinterpret_cast<T*>(&d[0]);
}
delete [] d;
}-
if (!m_iodevice.is_eof()){这里有越界风险,current 没有越界,但 current + size 不保证不会越界; -
char *d = new char[len];有内存泄漏的情况,没有 delete 的时机 -
有太多次的 memcpy 了,从socket 到 vector,再到这里的 d buffer,然后 copy 到变量 T
Metadata
Metadata
Assignees
Labels
No labels