From 96b8ffc426eb0ae0a7a9e05fb65aa0d2179843ac Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 21 May 2018 02:10:20 +0200 Subject: Fix bug with action gaps in response (invalid reference to local array) --- src/Database.cpp | 9 ++++++--- 1 file 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> 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> actionGaps; while(!deserializer.empty()) { - u8 userPublicKeyRaw[PUBLIC_KEY_NUM_BYTES]; - deserializer.extract(userPublicKeyRaw, PUBLIC_KEY_NUM_BYTES); + unique_ptr userPublicKeyRaw(new u8[PUBLIC_KEY_NUM_BYTES]); + deserializer.extract(userPublicKeyRaw.get(), PUBLIC_KEY_NUM_BYTES); u64 actionGapStart = deserializer.extract(); u64 actionGapRange = deserializer.extract(); - 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()) -- cgit v1.2.3