Skip to content

dgram: socket.send() crash when input array is modified #6616

Closed
@bnoordhuis

Description

@bnoordhuis

#4374 introduces a bug: it makes socket.send() accept an array but it's not resilient against that array getting modified afterwards:

$ node -e '
  var a = ["boom!"], s = dgram.createSocket("udp4");
  s.send(a, 1234);
  a.splice(0);
'
node: ../deps/uv/src/unix/udp.c:390: uv__udp_send: Assertion `nbufs > 0' failed.
Aborted (core dumped)

A secondary issue with #4374 is that it penalizes the common case of passing in a buffer by always wrapping it in an array.

/cc @mcollina @jasnell

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.dgramIssues and PRs related to the dgram subsystem / UDP.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions