Skip to content

.parent and .offset of Buffer and SlowBuffer .prototype throw an exception when accessed #3297

Closed
@wraithan

Description

@wraithan

I was writing a tool to scrape the APIs of everything and stumbled across these in the buffer module.

Repro:

Run the following JS on any version of node/io.js from 3.0.0 until 4.1.2 (current as of time of writing)

var buffer = require('buffer')
buffer.Buffer.prototype.parent
buffer.Buffer.prototype.offset
buffer.SlowBuffer.prototype.parent
buffer.SlowBuffer.prototype.offset

Example output:

buffer.js:311
    if (this.byteLength === 0 ||
            ^

TypeError: Method Uint8Array.byteLength called on incompatible receiver [object Object]
    at Buffer.get byteLength (native)
    at Buffer.Object.defineProperty.get [as parent] (buffer.js:311:13)
    at Object.<anonymous> (/Users/wmcdonald/devel/newrelic/api-scraper/bad-buffer.js:2:24)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:118:18)
    at node.js:952:3

CCing @trevnorris since he asked me to.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions