Skip to content

Commit 5c75008

Browse files
authored
Merge pull request #913 from dxdjgl/master
Fix/workaround for issue #910 Publisher crashes when curve encryption…
2 parents de50a21 + 586e24d commit 5c75008

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/NetMQ/Core/Patterns/XPub.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ protected override void XReadActivated(Pipe pipe)
176176
else
177177
{
178178
var unique = sub[0] == 0
179-
? m_subscriptions.Remove(sub.Slice(1), pipe)
180-
: m_subscriptions.Add(sub.Slice(1), pipe);
179+
? m_subscriptions.Remove(size == 1 ? new Span<byte>(): sub.Slice(1), pipe)
180+
: m_subscriptions.Add(size == 1 ? new Span<byte>() : sub.Slice(1), pipe);
181181

182182
// If the subscription is not a duplicate, store it so that it can be
183183
// passed to used on next recv call.

src/NetMQ/Core/Patterns/XSub.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ You should have received a copy of the GNU Lesser General Public License
1919
along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
*/
2121

22+
using System;
2223
using System.Diagnostics;
2324
using NetMQ.Core.Patterns.Utils;
2425

@@ -170,15 +171,15 @@ protected override bool XSend(ref Msg msg)
170171
if (!m_moreOut && size > 0 && msg[0] == 1)
171172
{
172173
// Process the subscription.
173-
if (m_subscriptions.Add(msg.Slice(1)))
174+
if (m_subscriptions.Add(size == 1 ? new Span<byte>() : msg.Slice(1)))
174175
{
175176
m_distribution.SendToAll(ref msg);
176177
return true;
177178
}
178179
}
179180
else if (!m_moreOut && size > 0 && msg[0] == 0)
180181
{
181-
if (m_subscriptions.Remove(msg.Slice(1)))
182+
if (m_subscriptions.Remove(size == 1 ?new Span<byte>() : msg.Slice(1)))
182183
{
183184
m_distribution.SendToAll(ref msg);
184185
return true;

0 commit comments

Comments
 (0)