Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid using deprecated Buffer constructor #94

Merged
merged 3 commits into from
Mar 2, 2018

Commits on Feb 22, 2018

  1. fix: avoid using deprecated Buffer constructor

    Buffer.alloc() is supported on Node.js >= 4.5.0, and allocates a zero-filled
    buffer on all supported versions.
    
    This solves two issues:
     * Buffer() constructor (aka 'new Buffer()') is deprecated, so avoid using it
     * On 4.x and 6.x, Buffer(number) is not zero-filled, so this code was
       allocating an uninitialized Buffer when file length was less than 150, so
       the behaviour of readShebang() was actually undefined in that case (as in
       could have returned anything, depending on the uninitialized memory chunk).
    
    Refs: https://nodejs.org/api/deprecations.html#deprecations_dep0005_buffer_constructor
    ChALkeR authored Feb 22, 2018
    Configuration menu
    Copy the full SHA
    1168334 View commit details
    Browse the repository at this point in the history

Commits on Mar 1, 2018

  1. readShebang: name reused inline constant

    '150' was used two times, it deserves a name.
    It's the size of the pre-read buffer.
    ChALkeR authored Mar 1, 2018
    Configuration menu
    Copy the full SHA
    4ebff01 View commit details
    Browse the repository at this point in the history
  2. readShebang: Buffer API compat for old Node.js

    To be reverted when dropping outdated Node.js versions support.
    ChALkeR authored Mar 1, 2018
    Configuration menu
    Copy the full SHA
    433f947 View commit details
    Browse the repository at this point in the history