Skip to content

Commit

Permalink
Merge pull request sass#3015 from mgreter/bugfix/3014-mem-leak-in-per…
Browse files Browse the repository at this point in the history
…mutate

Fix possible memory leak in permutation function
  • Loading branch information
mgreter committed Oct 27, 2019
2 parents e820c83 + 0537dd2 commit f7567ea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/permutate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ namespace Sass {
const std::vector<std::vector<T>>& in)
{

size_t L = in.size();
size_t n = 0;
size_t L = in.size(), n = 0;

// Exit early if any entry is empty
for (size_t i = 0; i < L; i += 1) {
if (in[i].size() == 0) return {};
}

size_t* state = new size_t[L + 1];
std::vector<std::vector<T>> out;

// First initialize all states for every permutation group
for (size_t i = 0; i < L; i += 1) {
if (in[i].size() == 0) return {};
state[i] = in[i].size() - 1;
}
while (true) {
Expand Down

0 comments on commit f7567ea

Please sign in to comment.