mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +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()
|
||||
{
|
||||
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;
|
||||
@ -88,10 +88,13 @@ 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_);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
/// copy constructor needed because of pimpl_
|
||||
IconvProcessor(IconvProcessor const &);
|
||||
/// assignment operator needed because of pimpl_
|
||||
void operator=(IconvProcessor const &);
|
||||
IconvProcessor & operator=(IconvProcessor const &);
|
||||
/// destructor
|
||||
~IconvProcessor();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user