Skip to content

Commit

Permalink
Fix 2 more memory leaks
Browse files Browse the repository at this point in the history
Discovered by running `./script/ci-build-plugin tests` locally.
Both were caused by not cleaning up on error.
  • Loading branch information
glebm authored and xzyfer committed Nov 20, 2018
1 parent 6c8285b commit 514c9c7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,9 +1103,15 @@ namespace Sass {
}
union Sass_Value* c_val = c_func(c_args, c_function, compiler());
if (sass_value_get_tag(c_val) == SASS_ERROR) {
error("error in C function " + c->name() + ": " + sass_error_get_message(c_val), c->pstate(), traces);
std::string message("error in C function " + c->name() + ": " + sass_error_get_message(c_val));
sass_delete_value(c_val);
sass_delete_value(c_args);
error(message, c->pstate(), traces);
} else if (sass_value_get_tag(c_val) == SASS_WARNING) {
error("warning in C function " + c->name() + ": " + sass_warning_get_message(c_val), c->pstate(), traces);
std::string message("warning in C function " + c->name() + ": " + sass_warning_get_message(c_val));
sass_delete_value(c_val);
sass_delete_value(c_args);
error(message, c->pstate(), traces);
}
result = c2ast(c_val, traces, c->pstate());

Expand Down
5 changes: 2 additions & 3 deletions src/sass_values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ extern "C" {
union Sass_Value* ADDCALL sass_value_op (enum Sass_OP op, const union Sass_Value* a, const union Sass_Value* b)
{

Sass::Value_Ptr rv;
Sass::Value_Obj rv;

try {

Expand Down Expand Up @@ -341,8 +341,7 @@ extern "C" {
if (!rv) return sass_make_error("invalid return value");

// convert result back to ast node
return ast_node_to_sass_value(rv);

return ast_node_to_sass_value(rv.ptr());
}

// simply pass the error message back to the caller for now
Expand Down

0 comments on commit 514c9c7

Please sign in to comment.