Skip to content

Commit

Permalink
Fixing minor issues with patch 1e15533. Solves rubinius#567.
Browse files Browse the repository at this point in the history
* Space for string null terminators wasn't being allocated.
  • Loading branch information
febuiles committed Jun 18, 2008
1 parent 1e15533 commit dd34e5c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/socket.rb
Expand Up @@ -45,7 +45,7 @@ def setsockopt(level, optname, optval)
# to doesn't do anything yet
def send(msg, flags, to = nil)
bytes = msg.length
buffer = MemoryPointer.new :char, bytes
buffer = MemoryPointer.new :char, bytes + 1
buffer.write_string msg
bytes_sent = Socket::Foreign.send(descriptor, buffer, bytes, flags)
Errno.handle 'send(2)' if bytes_sent < 0
Expand All @@ -55,7 +55,7 @@ def send(msg, flags, to = nil)

def recv(bytes_to_read, flags = 0)
bytes_to_read = Type.coerce_to bytes_to_read, Fixnum, :to_int
buffer = MemoryPointer.new :char, bytes_to_read
buffer = MemoryPointer.new :char, bytes_to_read + 1
bytes_read = Socket::Foreign.recv(descriptor, buffer, bytes_to_read, flags)
Errno.handle 'recv(2)' if bytes_read < 0
message = buffer.read_string
Expand Down

0 comments on commit dd34e5c

Please sign in to comment.