Skip to content

Commit aed868a

Browse files
committed
Merge pull request #1878 from mgreter/bugfix/unit-parse-handling
Fix potential issue with wrong std container usage
2 parents f561181 + 8899ff9 commit aed868a

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/ast.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,8 +1629,8 @@ namespace Sass {
16291629
std::vector<std::string> l_miss_nums(0);
16301630
std::vector<std::string> l_miss_dens(0);
16311631
// create copy since we need these for state keeping
1632-
std::vector<std::string> r_nums = n.numerator_units_;
1633-
std::vector<std::string> r_dens = n.denominator_units_;
1632+
std::vector<std::string> r_nums(n.numerator_units_);
1633+
std::vector<std::string> r_dens(n.denominator_units_);
16341634

16351635
std::vector<std::string>::const_iterator l_num_it = numerator_units_.begin();
16361636
std::vector<std::string>::const_iterator l_num_end = numerator_units_.end();
@@ -1650,6 +1650,7 @@ namespace Sass {
16501650
std::vector<std::string>::iterator r_num_it = r_nums.begin();
16511651
std::vector<std::string>::iterator r_num_end = r_nums.end();
16521652

1653+
bool found = false;
16531654
// search for compatible numerator
16541655
while (r_num_it != r_num_end)
16551656
{
@@ -1666,14 +1667,13 @@ namespace Sass {
16661667
factor *= conversion;
16671668
// remove item from vector
16681669
r_nums.erase(r_num_it);
1669-
// found it
1670+
// found numerator
1671+
found = true;
16701672
break;
16711673
}
16721674
// maybe we did not find any
1673-
if (r_num_it == r_num_end) {
1674-
// left numerator is leftover
1675-
l_miss_nums.push_back(l_num);
1676-
}
1675+
// left numerator is leftover
1676+
if (!found) l_miss_nums.push_back(l_num);
16771677
}
16781678

16791679
std::vector<std::string>::const_iterator l_den_it = denominator_units_.begin();
@@ -1688,6 +1688,7 @@ namespace Sass {
16881688
std::vector<std::string>::iterator r_den_it = r_dens.begin();
16891689
std::vector<std::string>::iterator r_den_end = r_dens.end();
16901690

1691+
bool found = false;
16911692
// search for compatible denominator
16921693
while (r_den_it != r_den_end)
16931694
{
@@ -1704,14 +1705,13 @@ namespace Sass {
17041705
factor *= conversion;
17051706
// remove item from vector
17061707
r_dens.erase(r_den_it);
1707-
// found it
1708+
// found denominator
1709+
found = true;
17081710
break;
17091711
}
17101712
// maybe we did not find any
1711-
if (r_den_it == r_den_end) {
1712-
// left denominator is leftover
1713-
l_miss_dens.push_back(l_den);
1714-
}
1713+
// left denominator is leftover
1714+
if (!found) l_miss_dens.push_back(l_den);
17151715
}
17161716

17171717
// check left-overs (ToDo: might cancel out)

0 commit comments

Comments
 (0)