Skip to content

Conversation

raslop
Copy link

@raslop raslop commented Jun 29, 2025

The QueryHandler has

  • a raw pointer to a JsonObject that is freed in the destructor
  • an implicit copy constructor

The implicit copy-ctor copies the pointer only,
where it probably should do a deep copy.

This leads to use-after-free situations,
e.g. when calling RecordingsResponder::getRecordingByRequest() at the beginning of `RecordingsResponder::saveMarks()'.

A quick fix for the bug at hand is to make a deep copy of the jsonObject, that's what this commit is about.

An alternative variant would be to forbid copying of the QueryHandler and fix the fallout, e.g. by passing a reference (instead of a copy) of the QueryHandler instance to functions like
RecordingsResponder::getRecordingByRequest().
Ideally a const reference would be passed, but that would incur more changes in to the QueryHandler, i.e. making all the get* and has* functions const, which are needlessly non-const currently.

I've opted for the smaller change (the quick fix), while I would probably prefer the alternative variant.

Let me know what you prefer.

The `QueryHandler` has

-   a raw pointer to a `JsonObject` that is freed in the destructor
-   an implicit copy constructor

The implicit copy-ctor copies the pointer only,
where it probably should do a deep copy.

This leads to use-after-free situations,
e.g. when calling `RecordingsResponder::getRecordingByRequest()`
at the beginning of `RecordingsResponder::saveMarks()'.

A quick fix for the bug at hand is to make a deep copy of the `jsonObject`,
that's what this commit is about.

An alternative variant would be to forbid copying of the `QueryHandler` and fix
the fallout, e.g. by passing a reference (instead of a copy) of the
`QueryHandler` instance to functions like
`RecordingsResponder::getRecordingByRequest()`.
Ideally a `const` reference would be passed, but that would incur more
changes in to the `QueryHandler`, i.e. making all the `get*` and `has*`
functions `const`, which are needlessly non-const currently.

I've opted for the smaller change (the quick fix),
while I would probably prefer the alternative variant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant