From aa2dd8491ca2107ca525bfe21af01da3ee301898 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 1 May 2016 15:56:10 +0200 Subject: [PATCH] Fixed a segfault in the buffer on track deletion, added a WARN-level message when/if something similar occurs. --- lib/shared_memory.cpp | 3 +++ src/input/input_buffer.cpp | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/shared_memory.cpp b/lib/shared_memory.cpp index 49a3a4b1..9af28ed8 100644 --- a/lib/shared_memory.cpp +++ b/lib/shared_memory.cpp @@ -1116,6 +1116,9 @@ namespace IPC { userConnection::userConnection(char * _data) { data = _data; + if (!data){ + WARN_MSG("userConnection created with null pointer!"); + } } unsigned long userConnection::getTrackId(size_t offset) const { diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index dea4efc1..444bce24 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -514,14 +514,18 @@ namespace Mist { nProxy.curPage.erase(tid); bufferLocations[tid].erase(bufferLocations[tid].begin()); } - if (pushLocation.count(it->first)){ - //Reset the userpage, to allow repushing from TS - IPC::userConnection userConn(pushLocation[it->first]); - for (int i = 0; i < SIMUL_TRACKS; i++){ - if (userConn.getTrackId(i) == it->first) { - userConn.setTrackId(i, 0); - userConn.setKeynum(i, 0); - break; + if (pushLocation.count(it->first)) { + // \todo Debugger says this is null sometimes. It shouldn't be. Figure out why! + // For now, this if will prevent crashes in these cases. + if (pushLocation[it->first]){ + //Reset the userpage, to allow repushing from TS + IPC::userConnection userConn(pushLocation[it->first]); + for (int i = 0; i < SIMUL_TRACKS; i++) { + if (userConn.getTrackId(i) == it->first) { + userConn.setTrackId(i, 0); + userConn.setKeynum(i, 0); + break; + } } } pushLocation.erase(it->first);