Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(core): add missing nullptr check
Browse files Browse the repository at this point in the history
fix #4324
  • Loading branch information
sudden6 committed May 6, 2017
1 parent 6a6e30d commit 407413c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/core/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ Tox_Options initToxOptions(const QByteArray& savedata)
toxOptions.proxy_type = TOX_PROXY_TYPE_NONE;
toxOptions.proxy_host = nullptr;
toxOptions.proxy_port = 0;
toxOptions.savedata_type = !savedata.isNull() ? TOX_SAVEDATA_TYPE_TOX_SAVE
: TOX_SAVEDATA_TYPE_NONE;
toxOptions.savedata_type = !savedata.isNull() ? TOX_SAVEDATA_TYPE_TOX_SAVE : TOX_SAVEDATA_TYPE_NONE;
toxOptions.savedata_data = reinterpret_cast<const uint8_t*>(savedata.data());
toxOptions.savedata_length = savedata.size();

Expand Down Expand Up @@ -239,6 +238,10 @@ void Core::makeTox(QByteArray savedata)
*/
void Core::makeAv()
{
if (!tox) {
qCritical() << "No Tox instance, can't create ToxAV";
return;
}
av = new CoreAV(tox);
if (!av->getToxAv()) {
qCritical() << "Toxav core failed to start";
Expand Down Expand Up @@ -443,11 +446,7 @@ void Core::onFriendMessage(Tox*, uint32_t friendId, TOX_MESSAGE_TYPE type, const
emit static_cast<Core*>(core)->friendMessageReceived(friendId, msg, isAction);
}

void Core::onFriendNameChange(Tox*,
uint32_t friendId,
const uint8_t* cName,
size_t cNameSize,
void* core)
void Core::onFriendNameChange(Tox*, uint32_t friendId, const uint8_t* cName, size_t cNameSize, void* core)
{
QString newName = ToxString(cName, cNameSize).getQString();
emit static_cast<Core*>(core)->friendUsernameChanged(friendId, newName);
Expand Down Expand Up @@ -1470,7 +1469,9 @@ void Core::setNospam(uint32_t nospam)
void Core::killTimers(bool onlyStop)
{
assert(QThread::currentThread() == coreThread);
av->stop();
if (av) {
av->stop();
}
toxTimer->stop();
if (!onlyStop) {
delete toxTimer;
Expand Down

0 comments on commit 407413c

Please sign in to comment.