mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2025-02-15 06:37:17 +02:00
![Las Safin](/assets/img/avatar_default.png)
Casting function pointers seems to be almost always UB. See https://stackoverflow.com/questions/559581/casting-a-function-pointer-to-another-type Fixed by doing the casting of `void*` to `std::string*` inside the function instead. Caught by UBSan.
11 lines
257 B
C++
11 lines
257 B
C++
#include "string_callback.hh"
|
|
|
|
namespace nix::testing {
|
|
|
|
void observe_string_cb(const char * start, unsigned int n, void * user_data)
|
|
{
|
|
auto user_data_casted = reinterpret_cast<std::string *>(user_data);
|
|
*user_data_casted = std::string(start);
|
|
}
|
|
|
|
}
|