Skip to content

Commit

Permalink
Merge pull request zeromq#532 from igvk/monitorevent_null
Browse files Browse the repository at this point in the history
Check m_addr for null in MonitorEvent.Write
  • Loading branch information
somdoron committed Apr 22, 2016
2 parents ed1d643 + 42e72e7 commit b1dddc3
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/NetMQ/Core/MonitorEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private MonitorEvent(SocketEvents monitorEvent, [NotNull] string addr, [NotNull]

public void Write([NotNull] SocketBase s)
{
int size = 4 + 1 + m_addr.Length + 1; // event + len(addr) + addr + flag
int size = 4 + 1 + (m_addr?.Length ?? 0) + 1; // event + len(addr) + addr + flag

if (m_flag == ValueInteger)
size += 4;
Expand All @@ -77,12 +77,16 @@ public void Write([NotNull] SocketBase s)
ByteArraySegment buffer = new byte[size];
buffer.PutInteger(Endianness.Little, (int)m_monitorEvent, pos);
pos += 4;
buffer[pos++] = (byte)m_addr.Length;

// was not here originally
if (m_addr != null)
{
buffer[pos++] = (byte)m_addr.Length;

// was not here originally

buffer.PutString(m_addr, pos);
pos += m_addr.Length;
buffer.PutString(m_addr, pos);
pos += m_addr.Length;
}

buffer[pos++] = ((byte)m_flag);
if (m_flag == ValueInteger)
Expand Down

0 comments on commit b1dddc3

Please sign in to comment.