forked from Kistler-Group/sdbus-cpp
* fix: Use-after-return in synchronous calls This bug was introduced byc39bc637b8and can be reproduced by configuring with cmake -S . -B build -DBUILD_TESTS=yes -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_FLAGS="-Wno-error=deprecated-copy -fno-omit-frame-pointer -fsanitize=address -fsanitize-address-use-after-scope" and running `cmake --buid build && cmake --build build -t test` or `build/tests/sdbus-c++-integration-tests --gtest_filter=SdbusTestObject.HandlesCorrectlyABulkOfParallelServerSideAsyncMethods` The issue is that `sdbus_async_reply_handler` can call `removeCall`, which writes to `data->finished`, but `data` can point to the stack of `sendMethodCallMessageAndWaitForReply`, which can return as soon as `asyncCallData->callback` is called. As a fix, I restored some of the logic removed inc39bc637b8. Specifically, in `sdbus_async_reply_handler`, I make a copy of some data from `asyncCallData` (a new `state` field instead of `slot`), and in the `SCOPE_GUARD`, I don't call `removeCall` if the call was actually synchronous. * refactor: use enum class instead of int --------- Co-authored-by: David Reiss <dreiss@meta.com> Co-authored-by: Stanislav Angelovič <stanislav.angelovic@protonmail.com>