diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-05-21 02:10:20 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 23:25:46 +0200 |
commit | 96b8ffc426eb0ae0a7a9e05fb65aa0d2179843ac (patch) | |
tree | da1f9c7dcd9b31fb57e75511dc4e6c167537daac /src | |
parent | 84d2aa195d93a5161dceb760d5a7a5ebf458dd81 (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()) |