From 807a8ae8f6aca56e3e809aa19f4034a323f1b987 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 14 Apr 2013 18:13:08 +0200 Subject: [PATCH 1/1] Fix a crash on re-exec if a client was not in SENDING_DATA. --- client.cpp | 2 +- server.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client.cpp b/client.cpp index 54373d4..f2d60a6 100644 --- a/client.cpp +++ b/client.cpp @@ -51,7 +51,7 @@ Client::Client(const ClientProto &serialized, Stream *stream) header_or_error_bytes_sent(serialized.header_or_error_bytes_sent()), stream_pos(serialized.stream_pos()) { - if (stream->mark_pool != NULL) { + if (stream != NULL && stream->mark_pool != NULL) { fwmark = stream->mark_pool->get_mark(); } else { fwmark = 0; // No mark. diff --git a/server.cpp b/server.cpp index 949d6a4..9517b54 100644 --- a/server.cpp +++ b/server.cpp @@ -153,7 +153,13 @@ void Server::add_client(int sock) void Server::add_client_from_serialized(const ClientProto &client) { MutexLock lock(&mutex); - Stream *stream = find_stream(client.stream_id()); + Stream *stream; + map::iterator stream_it = streams.find(client.stream_id()); + if (stream_it == streams.end()) { + stream = NULL; + } else { + stream = stream_it->second; + } clients.insert(make_pair(client.sock(), Client(client, stream))); Client *client_ptr = &clients[client.sock()]; -- 2.39.2