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

Value in expression is always undefined #2

Open
AndreasGassmann opened this issue Nov 5, 2019 · 0 comments
Open

Value in expression is always undefined #2

AndreasGassmann opened this issue Nov 5, 2019 · 0 comments

Comments

@AndreasGassmann
Copy link

During a review of our dependencies, we noticed this snippet here: https://github.com/QuantumExplorer/groestl-hash-js/blob/master/lib/groestl.js#L1079

var B64 = function(n, x) {
  if (n === 7) {
    return x.lo & 0xFF;
  }
  var bits = (7 - n) * 8;
  if (bits >= 32) { //faster than >= 32
    return (x.hi >>> (bits - 32)) & 0xFF;
  }
  else {
    var bitsOff32 = 32 - bits,
      toMoveDown = this.hi << bitsOff32 >>> bitsOff32;
    return (x.lo >>> bits | (toMoveDown << bitsOff32)) & 0xFF;
  }
}

On line 1079 there is reference to this.hi. In this context, this refers to the object that this function belongs to, but I don't think hi is ever defined there. So the value of this.hi is always undefined.

This means that toMoveDown = this.hi << bitsOff32 >>> bitsOff32; will always be 0.

Is this intended or a bug?

@AndreasGassmann AndreasGassmann changed the title Question about one of the Question about one of the functions Nov 5, 2019
@AndreasGassmann AndreasGassmann changed the title Question about one of the functions Value in expression is always undefined Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant