| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 071c72a commit 5479562
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -308,6 +308,8 @@ Buffer.byteLength = byteLength; | |||
| 308 | 308 | Object.defineProperty(Buffer.prototype, 'parent', { | |
| 309 | 309 | enumerable: true, | |
| 310 | 310 | get: function() { | |
| 311 | + if (!(this instanceof Buffer)) | ||
| 312 | + return undefined; | ||
| 311 | 313 | if (this.byteLength === 0 || | |
| 312 | 314 | this.byteLength === this.buffer.byteLength) { | |
| 313 | 315 | return undefined; | |
@@ -318,6 +320,8 @@ Object.defineProperty(Buffer.prototype, 'parent', { | |||
| 318 | 320 | Object.defineProperty(Buffer.prototype, 'offset', { | |
| 319 | 321 | enumerable: true, | |
| 320 | 322 | get: function() { | |
| 323 | + if (!(this instanceof Buffer)) | ||
| 324 | + return undefined; | ||
| 321 | 325 | return this.byteOffset; | |
| 322 | 326 | } | |
| 323 | 327 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1224,3 +1224,10 @@ assert.throws(function() { | |||
| 1224 | 1224 | assert.throws(function() { | |
| 1225 | 1225 | new Buffer(null); | |
| 1226 | 1226 | }, /must start with number, buffer, array or string/); | |
| 1227 | + | ||
| 1228 | + | ||
| 1229 | + // Test prototype getters don't throw | ||
| 1230 | + assert.equal(Buffer.prototype.parent, undefined); | ||
| 1231 | + assert.equal(Buffer.prototype.offset, undefined); | ||
| 1232 | + assert.equal(SlowBuffer.prototype.parent, undefined); | ||
| 1233 | + assert.equal(SlowBuffer.prototype.offset, undefined); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments