Skip to content

Commit

Permalink
Fix for crash in listening process
Browse files Browse the repository at this point in the history
  • Loading branch information
Mandar-Shinde authored Jun 10, 2016
1 parent ef3b21a commit 430b8f9
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Client-C++/Worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ void Worker::run()
char len[4];
cin.read(len, 4);
unsigned int ilen = *reinterpret_cast<unsigned int *>(len);
char *inMsg = new char[ilen];
memset(inMsg,0,ilen+1);
cin.read(inMsg, ilen);
string inStr(inMsg);
delete[] inMsg;
QString sline(inStr.c_str());
emit UpdateMessage(sline);
if(ilen<1024 && ilen>1)
{
char *inMsg = new char[ilen];
memset(inMsg,0,ilen+1);
cin.read(inMsg, ilen);
string inStr(inMsg);
delete[] inMsg;
QString sline(inStr.c_str());
emit UpdateMessage(sline);
}else{
QThread::msleep(1000);
}
}while(true);
}

0 comments on commit 430b8f9

Please sign in to comment.