Fix crash due to RsChatAvatarItem uninitialized pointer

Caught signal 11 (SIGSEGV)
stack trace:
retroshare( 0xbbd2da)[0x558ccf46a2da]
retroshare(CrashStackTrace::abortHandler(int) 0xeb)[0x558ccf471c5c]
/lib64/libc.so.6( 0x38f80)[0x7f6ef6facf80]
/lib64/libc.so.6(realloc 0x54)[0x7f6ef6fffef4]
retroshare(RsTypeSerializer::RawMemoryWrapper::serial_process(RsGenericSerializer::SerializeJob, RsGenericSerializer::SerializeContext&) 0x5d4)[0x558ccfcddad0]
retroshare(std::enable_if<std::is_base_of<RsSerializable, RsTypeSerializer::RawMemoryWrapper>::value, void>::type RsTypeSerializer::serial_process<RsTypeSerializer::RawMemoryWrapper>(RsGenericSerializer::SerializeJob, RsGenericSerializer::SerializeContext&, RsTypeSerializer::RawMemoryWrapper&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) 0x9d)[0x558ccfb3da66]
retroshare(RsChatAvatarItem::serial_process(RsGenericSerializer::SerializeJob, RsGenericSerializer::SerializeContext&) 0x84)[0x558ccff90ba6]
retroshare(RsServiceSerializer::deserialise(void*, unsigned int*) 0x403)[0x558ccfcd96e9]
retroshare(RsSerialiser::deserialise(void*, unsigned int*) 0x38e)[0x558ccfb5a1a8]
retroshare(pqiSSLstore::readPkt(RsItem**) 0x3f9)[0x558ccfad329f]
retroshare(pqiSSLstore::GetItem() 0xbb)[0x558ccfad2d9f]
retroshare(pqiSSLstore::getEncryptedItems(std::__cxx11::list<RsItem*, std::allocator<RsItem*> >&) 0x3e)[0x558ccfad2c26]
retroshare(p3Config::loadAttempt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::list<RsItem*, std::allocator<RsItem*> >&) 0xf8)[0x558ccfab20d0]
retroshare(p3Config::loadConfig() 0xeb)[0x558ccfab1d69]
retroshare(p3Config::loadConfiguration(t_RsGenericIdType<20u, false, (RsGenericIdType)2>&) 0x1c)[0x558ccfab1c7c]
retroshare(p3ConfigMgr::loadConfig() 0x97)[0x558ccfab17f3]
retroshare(p3ConfigMgr::loadConfiguration() 0x18)[0x558ccfab1758]
retroshare(RsServer::StartupRetroShare() 0x4407)[0x558ccfb02fab]
retroshare(main 0x17e2)[0x558ccf46d291]
/lib64/libc.so.6(__libc_start_main 0xeb)[0x7f6ef6f97e9b]
retroshare(_start 0x2a)[0x558ccf438c9a]
D 1585687209 void RetroDb::closeDb() sqlite3_close return: 0
D 1585687209 void RetroDb::closeDb() sqlite3_close return: 0
Memory still in use at end of program: 24776 bytes.
This commit is contained in:
Gioacchino Mazzurco 2020-03-31 23:20:08 +02:00
parent 0187bf2f2f
commit 0d1524aa12
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
2 changed files with 12 additions and 15 deletions

View File

@ -70,15 +70,6 @@ void RsChatMsgItem::serial_process(RsGenericSerializer::SerializeJob j,RsGeneric
/*************************************************************************/
RsChatAvatarItem::~RsChatAvatarItem()
{
if(image_data != NULL)
{
free(image_data) ;
image_data = NULL ;
}
}
void RsChatLobbyBouncingObject::serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,lobby_id,"lobby_id") ;

View File

@ -346,14 +346,20 @@ class RsChatStatusItem: public RsChatItem
//
class RsChatAvatarItem: public RsChatItem
{
public:
RsChatAvatarItem() :RsChatItem(RS_PKT_SUBTYPE_CHAT_AVATAR) {setPriorityLevel(QOS_PRIORITY_RS_CHAT_AVATAR_ITEM) ;}
public:
RsChatAvatarItem():
RsChatItem(RS_PKT_SUBTYPE_CHAT_AVATAR),
image_size(0), image_data(nullptr)
{ setPriorityLevel(QOS_PRIORITY_RS_CHAT_AVATAR_ITEM); }
virtual ~RsChatAvatarItem() ;
void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx);
~RsChatAvatarItem() override { free(image_data); }
uint32_t image_size ; // size of data in bytes
unsigned char *image_data ; // image
void serial_process(
RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx) override;
uint32_t image_size; /// size of data in bytes
unsigned char* image_data ; /// image data
};