Skip to content

Int32 overflow when creating a buffer #12553

@rgrannell1

Description

@rgrannell1

I noticed that there's an unhandled overflow error in stream.Readable in work earlier today; when large values are supplied as highWaterMark the value used by the created object wraps around to a negative number. This didn't cause us massive problems, but it is a little difficult to debug (given that most people won't read the contents of _readableState)

console.log(
	require('stream').Readable({
		highWaterMark: 2147483647
	})._readableState.highWaterMark
)

console.log(
	require('stream').Readable({
		highWaterMark: 2147483647 + 1
	})._readableState.highWaterMark
)

which outputs:

2147483647
-2147483648

This should ideally throw an error, or support larger numeric values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions