fixed a few bugs (uninitialized memory mostly)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7234 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-04-05 12:27:40 +00:00
parent 2a5854188e
commit f2380d0926
2 changed files with 12 additions and 4 deletions

View File

@ -135,7 +135,8 @@ TEST(libretroshare_serialiser, RsTlvFileData)
d1.file.age = 0; d1.file.age = 0;
d1.file.pop = 0; d1.file.pop = 0;
char data[15]; unsigned char data[15];
RSRandom::random_bytes(data,15) ;
d1.binData.setBinData(data, 15); d1.binData.setBinData(data, 15);
d1.file_offset = 222; d1.file_offset = 222;

View File

@ -40,7 +40,7 @@ RsSerialType* init_item(RsChatMsgItem& cmi)
return new RsChatSerialiser(); return new RsChatSerialiser();
} }
RsSerialType* init_item(RsChatLobbyListRequestItem& cmi) RsSerialType* init_item(RsChatLobbyListRequestItem& )
{ {
return new RsChatSerialiser(); return new RsChatSerialiser();
} }
@ -50,13 +50,17 @@ RsSerialType* init_item(RsChatLobbyListItem& cmi)
cmi.lobby_ids.resize(n) ; cmi.lobby_ids.resize(n) ;
cmi.lobby_names.resize(n) ; cmi.lobby_names.resize(n) ;
cmi.lobby_topics.resize(n) ;
cmi.lobby_counts.resize(n) ; cmi.lobby_counts.resize(n) ;
cmi.lobby_privacy_levels.resize(n) ;
for(int i=0;i<n;++i) for(int i=0;i<n;++i)
{ {
cmi.lobby_ids[i] = RSRandom::random_u64() ; cmi.lobby_ids[i] = RSRandom::random_u64() ;
randString(5+(rand()%10), cmi.lobby_names[i]); randString(5+(rand()%10), cmi.lobby_names[i]);
randString(20+(rand()%15), cmi.lobby_topics[i]);
cmi.lobby_counts[i] = RSRandom::random_u32() ; cmi.lobby_counts[i] = RSRandom::random_u32() ;
cmi.lobby_privacy_levels[i] = RSRandom::random_u32()%3 ;
} }
return new RsChatSerialiser(); return new RsChatSerialiser();
@ -75,7 +79,10 @@ RsSerialType* init_item(RsChatLobbyMsgItem& cmi)
} }
RsSerialType *init_item(RsChatLobbyEventItem& cmi) RsSerialType *init_item(RsChatLobbyEventItem& cmi)
{ {
cmi.event_type = rand()%256 ; cmi.lobby_id = RSRandom::random_u64() ;
cmi.msg_id = RSRandom::random_u64() ;
randString(20, cmi.nick);
cmi.event_type = RSRandom::random_u32()%256 ;
randString(20, cmi.string1); randString(20, cmi.string1);
return new RsChatSerialiser(); return new RsChatSerialiser();
@ -193,7 +200,7 @@ bool operator ==(const RsChatLobbyListItem& cmiLeft,const RsChatLobbyListItem&
} }
return true ; return true ;
} }
bool operator ==(const RsChatLobbyListRequestItem& cmiLeft,const RsChatLobbyListRequestItem& cmiRight) bool operator ==(const RsChatLobbyListRequestItem& ,const RsChatLobbyListRequestItem& )
{ {
return true ; return true ;
} }