CloudPolis / webdav-client-cpp

:cloud: C++ WebDAV Client provides easy and convenient to work with WebDAV-servers.
http://cloudpolis.github.io/webdav-client-cpp/
Other
120 stars 52 forks source link

Dangerous code regarding parameter lifetime #45

Closed horde3d closed 6 years ago

horde3d commented 6 years ago

Passing the parameters by reference to the std::thread object probably will result in a crash for most users, if they don't take care that those parameters have to be valid and constant for the whole thread lifetime.

https://github.com/CloudPolis/webdav-client-cpp/blob/5a92c825e84ba0a3d1907b8cbdaeee7fa3079bb5/sources/client.cpp#L556

Instead of capturing the parameters with a lambda expression it would be probably better to pass the parameters as a thread local copy, e.g. by passing the function parameters as parameters to the thread instance.

rusdevops commented 6 years ago

Thank you for your code review 👍