Skip to content
Snippets Groups Projects
Commit 39f98b5d authored by Brad King's avatar Brad King
Browse files

Encoding: Add self-assignment check to CommandLineArguments

This was caught by the HP compiler warning:

 warning #4285-D: operator= does not have a check for the source and
 destination addresses being non-identical

Change-Id: I074a33410402b2b872dee03df3d4006ffe32f111
parent 36982798
No related branches found
No related tags found
No related merge requests found
......@@ -110,16 +110,19 @@ Encoding::CommandLineArguments::
Encoding::CommandLineArguments&
Encoding::CommandLineArguments::operator=(const CommandLineArguments& other)
{
size_t i;
for(i=0; i<this->argv_.size(); i++)
if(this != &other)
{
free(this->argv_[i]);
}
size_t i;
for(i=0; i<this->argv_.size(); i++)
{
free(this->argv_[i]);
}
this->argv_.resize(other.argv_.size());
for(i=0; i<this->argv_.size(); i++)
{
this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
this->argv_.resize(other.argv_.size());
for(i=0; i<this->argv_.size(); i++)
{
this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
}
}
return *this;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment