Skip to content

Commit c68651b

Browse files
authored
Merge pull request #220 from CosmWasm/create-patch-0.13.1
Create patch 0.13.1 to fix memory leak
2 parents 403b5f4 + 756d55d commit c68651b

File tree

5 files changed

+49
-66
lines changed

5 files changed

+49
-66
lines changed

Cargo.lock

Lines changed: 38 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ default = []
3030
backtraces = []
3131

3232
[dependencies]
33-
cosmwasm-std = { version = "0.13.0", features = ["iterator"]}
34-
cosmwasm-vm = { version = "0.13.0", features = ["iterator"] }
33+
cosmwasm-std = { version = "0.13.2", features = ["iterator"]}
34+
cosmwasm-vm = { version = "0.13.2", features = ["iterator"] }
3535
errno = "0.2"
3636
serde_json = "1.0"
3737
thiserror = "1.0"

api/libwasmvm.dylib

-5.26 KB
Binary file not shown.

api/libwasmvm.so

-592 Bytes
Binary file not shown.

src/iterator.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ impl GoIter {
7878
}
7979
}
8080

81+
// In this block, we use Buffer::read() for both `key_buf` and `value_buf`
82+
// in order to preserve the behaviour for optional values. Buffer::consume()
83+
// does not return an Option. Since we `return` in none of the cases, we can
84+
// cleanup afterwards. With CosmWasm 0.14 this code is completely refactored.
8185
let okey = unsafe { key_buf.read() };
8286
let result = match okey {
8387
Some(key) => {
@@ -92,6 +96,11 @@ impl GoIter {
9296
}
9397
None => Ok(None),
9498
};
99+
100+
// Clean up memory allocations created by us
101+
let _key = unsafe { key_buf.consume() };
102+
let _value = unsafe { value_buf.consume() };
103+
95104
(result, gas_info)
96105
}
97106
}

0 commit comments

Comments
 (0)