Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Fix heap-use-after-free in eval.cpp (#2859)
Browse files Browse the repository at this point in the history
Fixes #2813
  • Loading branch information
glebm authored and xzyfer committed Apr 5, 2019
1 parent 2050492 commit fef6c6a
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1588,21 +1588,6 @@ namespace Sass {
// a selector schema may or may not connect to parent?
bool chroot = s->connect_parent() == false;
Selector_List_Obj sl = p.parse_selector_list(chroot);
auto vec_str_rend = ctx.strings.rend();
auto vec_str_rbegin = ctx.strings.rbegin();
// remove the first item searching from the back
// we cannot assume our item is still the last one
// order is not important, so we can optimize this
auto it = std::find(vec_str_rbegin, vec_str_rend, temp_cstr);
// undefined behavior if not found!
if (it != vec_str_rend) {
// overwrite with last item
*it = ctx.strings.back();
// remove last one from vector
ctx.strings.pop_back();
// free temporary copy
free(temp_cstr);
}
flag_is_in_selector_schema.reset();
return operator()(sl);
}
Expand Down

0 comments on commit fef6c6a

Please sign in to comment.