nim-lang / nim-zmq

Nim ZMQ wrapper
https://nim-lang.github.io/nim-zmq/zmq.html
MIT License
65 stars 17 forks source link

IndexError, if the length of the received message is 0 #11

Closed AvdN closed 5 years ago

AvdN commented 5 years ago

If msg_size(m) equals 0 you cannot take the address of result[0] leading to an IndexError.

    result = newString( msg_size(m) )
    copyMem(addr(result[0]), msg_data(m), result.len)

One should only do the copyMem if there are actual bytes to be copied.