Browse files

Merge pull request #33 from somia/master

Fix for bug with SetSockOpt*, where wrong value size can be passed through to the C function.
  • Loading branch information...
2 parents 8599fc4 + e568f43 commit 6b880ff8a6af1dfe89b8b1a9b8f3d548362c437b @alecthomas committed Sep 20, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 zmq.go
View
6 zmq.go
@@ -236,7 +236,7 @@ func (s *zmqSocket) destroy() {
// Set an int option on the socket.
// int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);
func (s *zmqSocket) SetSockOptInt(option IntSocketOption, value int) error {
- if C.zmq_setsockopt(s.s, C.int(option), unsafe.Pointer(&value), C.size_t(unsafe.Sizeof(&value))) != 0 {
+ if C.zmq_setsockopt(s.s, C.int(option), unsafe.Pointer(&value), C.size_t(unsafe.Sizeof(value))) != 0 {
return errno()
}
return nil
@@ -245,7 +245,7 @@ func (s *zmqSocket) SetSockOptInt(option IntSocketOption, value int) error {
// Set an int64 option on the socket.
// int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);
func (s *zmqSocket) SetSockOptInt64(option Int64SocketOption, value int64) error {
- if C.zmq_setsockopt(s.s, C.int(option), unsafe.Pointer(&value), C.size_t(unsafe.Sizeof(&value))) != 0 {
+ if C.zmq_setsockopt(s.s, C.int(option), unsafe.Pointer(&value), C.size_t(unsafe.Sizeof(value))) != 0 {
return errno()
}
return nil
@@ -254,7 +254,7 @@ func (s *zmqSocket) SetSockOptInt64(option Int64SocketOption, value int64) error
// Set a uint64 option on the socket.
// int zmq_setsockopt (void *s, int option, const void *optval, size_t optvallen);
func (s *zmqSocket) SetSockOptUInt64(option UInt64SocketOption, value uint64) error {
- if C.zmq_setsockopt(s.s, C.int(option), unsafe.Pointer(&value), C.size_t(unsafe.Sizeof(&value))) != 0 {
+ if C.zmq_setsockopt(s.s, C.int(option), unsafe.Pointer(&value), C.size_t(unsafe.Sizeof(value))) != 0 {
return errno()
}
return nil

0 comments on commit 6b880ff

Please sign in to comment.