bufferutils/script: allow for invalid pushDatInts, fixes

This commit is contained in:
Daniel Cousens 2015-03-04 20:48:28 +11:00
parent 2f100e0eae
commit ec66ca9b1a
2 changed files with 7 additions and 1 deletions

View file

@ -38,8 +38,11 @@ Script.fromBuffer = function (buffer) {
// data chunk
if ((opcode > opcodes.OP_0) && (opcode <= opcodes.OP_PUSHDATA4)) {
var d = bufferutils.readPushDataInt(buffer, i)
i += d.size
// did reading a pushDataInt fail? return non-chunked script
if (d === null) return new Script(buffer, [])
i += d.size
var data = buffer.slice(i, i + d.number)
i += d.number