Skip to content

Commit b389919

Browse files
Fix mem leak?
1 parent 1329cdc commit b389919

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

include/libsemigroups/konieczny.tpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ namespace libsemigroups {
6969
Runner::operator=(that);
7070

7171
free_internals();
72+
_gens.clear();
73+
InternalVecCopy()(that._gens, _gens);
7274

7375
// deal with all the easy data first
7476
_adjoined_identity_contained = that._adjoined_identity_contained;
@@ -78,15 +80,16 @@ namespace libsemigroups {
7880
_group_indices = that._group_indices;
7981
_group_indices_rev = that._group_indices_rev;
8082
_lambda_orb = that._lambda_orb;
81-
_one = this->internal_copy(that._one);
82-
_rank_state = new rank_state_type(*(that._rank_state));
83-
_ranks = that._ranks;
84-
_reps_processed = that._reps_processed;
85-
_rho_orb = that._rho_orb;
86-
_run_initialised = that._run_initialised;
83+
if (_data_initialised) {
84+
_one = _gens.back();
85+
}
86+
_rank_state = new rank_state_type(*(that._rank_state));
87+
_ranks = that._ranks;
88+
_reps_processed = that._reps_processed;
89+
_rho_orb = that._rho_orb;
90+
_run_initialised = that._run_initialised;
8791

8892
_element_pool.init(_one);
89-
InternalVecCopy()(that._gens, _gens);
9093

9194
// Construct the new DClasses, and record a map from the addresses
9295
// of the old classes to the addresses of the corresponding new classes.
@@ -537,10 +540,10 @@ namespace libsemigroups {
537540
// _one is included in _gens
538541
InternalVecFree()(_gens);
539542
while (!_ranks.empty()) {
540-
for (auto rep_info : _regular_reps[max_rank()]) {
543+
for (auto& rep_info : _regular_reps[max_rank()]) {
541544
this->internal_free(rep_info._elt);
542545
}
543-
for (auto rep_info : _nonregular_reps[max_rank()]) {
546+
for (auto& rep_info : _nonregular_reps[max_rank()]) {
544547
this->internal_free(rep_info._elt);
545548
}
546549
_ranks.erase(max_rank());

0 commit comments

Comments
 (0)