artyom-beilis/cppcms

Private `auto_ptr` field in classes without copy constructors or copy assignment operators.

Opened this issue · 0 comments

I am now testing my new linter for checking smart pointer errors, and I have found something in your repo. Some of the classes declare a private auto_ptr field without defining a copy constructor or a copy assignment operator, which will cause the auto_ptr field becomes nullptr when it is copied. And this may cause a null pointer dereference problem when using the field after the object has been copied.
One solution to this issue is to declare both the copy constructor and the copy assignment operator to be deleted to prevent their objects being copied. Just like what is implicitly done when using unique_ptr.
I did not read all your code in your repo, but only reviewed the classes related to my reports. Therefore, I am not very sure whether my reports will really cause a crush. However, I think these reports worth being paid attention to.

Here are the reported classes:

class legacy_sync_pool : public application_specific_pool {

class mem_cache : public base_cache {

class event_loop_impl {

class date_format : public formatter<CharType> {

class date_format : public formatter<CharType> {

Hope these reports are useful to you. Please contact me if you have any questions.

Regares.