git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 8b6a2d4230e3065ae873a6c239315fd80e80eaa9

Interface: always take a copy of memory

Alex Beregszaszi committed on 8/25/2016, 2:39:12 AM
Parent: fa75e6ce5dba39ae90d9ff2364aad9b08d9c4e93

Files changed

interface.jschanged
interface.jsView
@@ -319,9 +319,9 @@
319319 }
320320
321321 this.takeGas(375 + length * 8 + numberOfTopics * 375)
322322
323- const data = this.getMemory(dataOffset, length)
323+ const data = this.getMemory(dataOffset, length).slice(0)
324324 let topics = []
325325
326326 if (numberOfTopics > 0) {
327327 topics.push(U256.fromMemory(this.getMemory(topic1, constants.U256_SIZE_BYTES)))
@@ -354,9 +354,9 @@
354354 create (valueOffset, dataOffset, length) {
355355 this.takeGas(32000)
356356
357357 const value = U256.fromMemory(this.getMemory(valueOffset, constants.U128_SIZE_BYTES))
358- const data = this.getMemory(dataOffset, length)
358+ const data = this.getMemory(dataOffset, length).slice(0)
359359 const result = this.environment.create(value, data)
360360 return result
361361 }
362362
@@ -377,9 +377,9 @@
377377
378378 // Load the params from mem
379379 const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES))
380380 const value = U256.fromMemory(this.getMemory(valueOffset, constants.U128_SIZE_BYTES))
381- const data = this.getMemory(dataOffset, dataLength)
381+ const data = this.getMemory(dataOffset, dataLength).slice(0)
382382 // Run the call
383383 const [result, errorCode] = this.environment.call(gas, address, value, data)
384384 this.setMemory(resultOffset, resultLength, result)
385385 return errorCode
@@ -402,9 +402,9 @@
402402
403403 // Load the params from mem
404404 const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES))
405405 const value = U256.fromMemory(this.getMemory(valueOffset, constants.U128_SIZE_BYTES))
406- const data = this.getMemory(dataOffset, dataLength)
406+ const data = this.getMemory(dataOffset, dataLength).slice(0)
407407 // Run the call
408408 const [result, errorCode] = this.environment.callCode(gas, address, value, data)
409409 this.setMemory(resultOffset, resultLength, result)
410410 return errorCode
@@ -425,9 +425,9 @@
425425 callDelegate (gas, addressOffset, dataOffset, dataLength, resultOffset, resultLength) {
426426 // FIXME: count properly
427427 this.takeGas(40)
428428
429- const data = this.getMemory(dataOffset, dataLength)
429+ const data = this.getMemory(dataOffset, dataLength).slice(0)
430430 const address = Address.fromMemory(this.getMemory(addressOffset, constants.ADDRESS_SIZE_BYTES))
431431 const [result, errorCode] = this.environment.callDelegate(gas, address, data)
432432 this.setMemory(resultOffset, resultLength, result)
433433 return errorCode
@@ -480,9 +480,9 @@
480480 * @param {integer} offset the offset of the output data.
481481 * @param {integer} length the length of the output data.
482482 */
483483 return (offset, length) {
484- this.environment.returnValue = this.getMemory(offset, length)
484+ this.environment.returnValue = this.getMemory(offset, length).slice(0)
485485 }
486486
487487 /**
488488 * Halt execution and register account for later deletion giving the remaining

Built with git-ssb-web