replay: fix potential invalid memory access

_subscriptions is a vector that is resized when needed. However there could
still be references to elements in the vector when the resize happens.
These references then become invalid.
Using a vector of pointers fixes that.
This commit is contained in:
Beat Küng
2018-08-06 07:15:51 +02:00
parent e4485fc8cf
commit e989c80205
2 changed files with 53 additions and 32 deletions
+3 -3
View File
@@ -58,9 +58,9 @@ namespace px4
class Replay : public ModuleBase<Replay>
{
public:
Replay() {}
Replay() = default;
virtual ~Replay() {}
virtual ~Replay();
/** @see ModuleBase */
static int task_spawn(int argc, char *argv[]);
@@ -205,7 +205,7 @@ protected:
*/
bool nextDataMessage(std::ifstream &file, Subscription &subscription, int msg_id);
std::vector<Subscription> _subscriptions;
std::vector<Subscription *> _subscriptions;
std::vector<uint8_t> _read_buffer;
private: