diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-05-21 02:10:20 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-05-21 02:10:22 +0200 |
commit | 7b225aa9fe31b38ada299f183b66cd2204eb9e10 (patch) | |
tree | 94ec881f4e8537d2fc324a28c1a8944b38642479 /src | |
parent | b3a75bf999e54663a31179ae1338d5431feb105f (diff) |
Fix bug with action gaps in response (invalid reference to local array)
Diffstat (limited to 'src')
-rw-r--r-- | src/Database.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/Database.cpp b/src/Database.cpp index 3f5ae2f..169c066 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -234,17 +234,20 @@ namespace odhtdb }); } + vector<unique_ptr<u8[]>> userPublicKeys; + // TODO(Performance improvement): Sort actions by gap start and do a binary search to check if raw data is the packet the peer wants DataViewMap<vector<ActionGap>> actionGaps; while(!deserializer.empty()) { - u8 userPublicKeyRaw[PUBLIC_KEY_NUM_BYTES]; - deserializer.extract(userPublicKeyRaw, PUBLIC_KEY_NUM_BYTES); + unique_ptr<u8[]> userPublicKeyRaw(new u8[PUBLIC_KEY_NUM_BYTES]); + deserializer.extract(userPublicKeyRaw.get(), PUBLIC_KEY_NUM_BYTES); u64 actionGapStart = deserializer.extract<u64>(); u64 actionGapRange = deserializer.extract<u64>(); - DataView userPublicKey(userPublicKeyRaw, PUBLIC_KEY_NUM_BYTES); + DataView userPublicKey(userPublicKeyRaw.get(), PUBLIC_KEY_NUM_BYTES); actionGaps[userPublicKey].push_back({ actionGapStart, actionGapRange }); + userPublicKeys.emplace_back(move(userPublicKeyRaw)); } if(actionGaps.empty()) |