mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Fix memory leak and assignment operator signature
The IconvProcessor assignment operator did not delete pimpl_ and used a non-standard signature. If you want to know why the standard signature is important, read "Effective C++" by Scott Meyers.
This commit is contained in:
parent
c2de96d2ed
commit
0e8fea0705
@ -61,7 +61,7 @@ struct IconvProcessor::Impl
|
|||||||
~Impl()
|
~Impl()
|
||||||
{
|
{
|
||||||
if (cd != invalid_cd && iconv_close(cd) == -1)
|
if (cd != invalid_cd && iconv_close(cd) == -1)
|
||||||
LYXERR0("Error returned from iconv_close(" << errno << ")");
|
LYXERR0("Error returned from iconv_close(" << errno << ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
iconv_t cd;
|
iconv_t cd;
|
||||||
@ -88,11 +88,14 @@ IconvProcessor::~IconvProcessor()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IconvProcessor::operator=(IconvProcessor const & other)
|
IconvProcessor & IconvProcessor::operator=(IconvProcessor const & other)
|
||||||
{
|
{
|
||||||
if (&other != this)
|
if (&other != this) {
|
||||||
|
delete pimpl_;
|
||||||
pimpl_ = new Impl(other.pimpl_->tocode_, other.pimpl_->fromcode_);
|
pimpl_ = new Impl(other.pimpl_->tocode_, other.pimpl_->fromcode_);
|
||||||
}
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IconvProcessor::init()
|
bool IconvProcessor::init()
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
/// copy constructor needed because of pimpl_
|
/// copy constructor needed because of pimpl_
|
||||||
IconvProcessor(IconvProcessor const &);
|
IconvProcessor(IconvProcessor const &);
|
||||||
/// assignment operator needed because of pimpl_
|
/// assignment operator needed because of pimpl_
|
||||||
void operator=(IconvProcessor const &);
|
IconvProcessor & operator=(IconvProcessor const &);
|
||||||
/// destructor
|
/// destructor
|
||||||
~IconvProcessor();
|
~IconvProcessor();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user