Skip to content

Commit

Permalink
Fix possible memory leak in permutation function
Browse files Browse the repository at this point in the history
Fixes sass#3014
  • Loading branch information
mgreter committed Oct 23, 2019
1 parent e820c83 commit 9064c51
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 one path 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 9064c51

Please sign in to comment.