Skip to content

Commit

Permalink
fix ressource leak in move assignment operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Aug 26, 2016
1 parent 1da8ee7 commit 5fffa02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/gsl_vector.cpp
Expand Up @@ -127,6 +127,9 @@ const GSL_vector& GSL_vector::operator=(const GSL_vector& rhs)

GSL_vector& GSL_vector::operator=(GSL_vector&& rhs) noexcept
{
if (vec)
gsl_vector_free(vec);

if (this != &rhs)
move_assign(std::move(rhs));

Expand Down
2 changes: 1 addition & 1 deletion test/test_gsl_vector.cpp
Expand Up @@ -141,7 +141,7 @@ BOOST_AUTO_TEST_CASE( test_move_assign )
v[1] = 2.;
v[2] = 3.;

GSL_vector v2;
GSL_vector v2(2);
v2 = std::move(v);

BOOST_CHECK(!v.raw());
Expand Down

0 comments on commit 5fffa02

Please sign in to comment.