Skip to content

Commit bc8be92

Browse files
committed
Fix memory access bug (Fixes Mac CI builds)
1 parent 7f2d973 commit bc8be92

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ compiler:
1616
# further speed up day by day travis-ci builds
1717
# re-enable this if you change the makefiles
1818
# this will still catch all coding errors!
19-
# - AUTOTOOLS=no COVERAGE=no BUILD=shared
2019
# - AUTOTOOLS=yes COVERAGE=no BUILD=static
2120

2221
env:
22+
- AUTOTOOLS=no COVERAGE=no BUILD=shared
2323
- AUTOTOOLS=no COVERAGE=yes BUILD=static
2424
- AUTOTOOLS=yes COVERAGE=no BUILD=shared
2525

@@ -31,6 +31,8 @@ matrix:
3131
exclude:
3232
- compiler: clang
3333
env: AUTOTOOLS=yes COVERAGE=yes BUILD=static
34+
- os: linux
35+
env: AUTOTOOLS=no COVERAGE=no BUILD=shared
3436
- os: osx
3537
compiler: gcc
3638
- os: osx

src/node.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,24 +284,31 @@ namespace Sass {
284284
// This is only used in Complex_Selector::unify_with for now, may need modifications to fit other needs
285285
Node Node::naiveTrim(Node& seqses, Context& ctx) {
286286

287-
SourcesSet sel_set;
288-
289287
vector<Node*> res;
288+
vector<Complex_Selector*> known;
289+
290+
NodeDeque::reverse_iterator seqsesIter = seqses.collection()->rbegin(),
291+
seqsesIterEnd = seqses.collection()->rend();
290292

291-
// Add all selectors we don't already have, everything else just add it blindly
292-
// We iterate from the back to the front, since in ruby we probably overwrite existing the items
293-
for (NodeDeque::iterator seqsesIter = seqses.collection()->end() - 1, seqsesIterEnd = seqses.collection()->begin() - 1; seqsesIter != seqsesIterEnd; --seqsesIter) {
293+
for (; seqsesIter != seqsesIterEnd; ++seqsesIter)
294+
{
294295
Node& seqs1 = *seqsesIter;
295296
if( seqs1.isSelector() ) {
296-
auto found = sel_set.find( seqs1.selector() );
297-
if( found == sel_set.end() ) {
298-
sel_set.insert(seqs1.selector());
297+
Complex_Selector* sel = seqs1.selector();
298+
vector<Complex_Selector*>::iterator it;
299+
bool found = false;
300+
for (it = known.begin(); it != known.end(); ++it) {
301+
if (**it == *sel) { found = true; break; }
302+
}
303+
if( !found ) {
304+
known.push_back(seqs1.selector());
299305
res.push_back(&seqs1);
300306
}
301307
} else {
302308
res.push_back(&seqs1);
303309
}
304310
}
311+
305312
Node result = Node::createCollection();
306313

307314
for (size_t i = res.size() - 1; i != string::npos; --i) {

0 commit comments

Comments
 (0)