Commit 3052263f by Stefan Penner

[LEAK FIX] create_string must be paired with a free

parent 4cf43ac9
......@@ -158,7 +158,9 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
CustomFunctionBridge *bridge = new CustomFunctionBridge(callback, ctx_w->is_sync);
ctx_w->function_bridges.push_back(bridge);
Sass_Function_Entry fn = sass_make_function(create_string(signature), sass_custom_function, bridge);
char* sig = create_string(signature);
Sass_Function_Entry fn = sass_make_function(sig, sass_custom_function, bridge);
free(sig);
sass_function_set_list_entry(fn_list, i, fn);
}
......@@ -267,7 +269,7 @@ NAN_METHOD(render) {
struct Sass_Data_Context* dctx = sass_make_data_context(source_string);
sass_context_wrapper* ctx_w = sass_make_context_wrapper();
if (ExtractOptions(options, dctx, ctx_w, false, false) >= 0) {
if (ExtractOptions(options, dctx, ctx_w, false, false) >= 0) {
int status = uv_queue_work(uv_default_loop(), &ctx_w->request, compile_it, (uv_after_work_cb)MakeCallback);
......@@ -290,6 +292,7 @@ NAN_METHOD(render_sync) {
}
sass_free_context_wrapper(ctx_w);
info.GetReturnValue().Set(result == 0);
}
......
......@@ -55,7 +55,7 @@ Nan::Persistent<v8::Function> CallbackBridge<T, L>::wrapper_constructor;
template <typename T, typename L>
CallbackBridge<T, L>::CallbackBridge(v8::Local<v8::Function> callback, bool is_sync) : callback(new Nan::Callback(callback)), is_sync(is_sync) {
/*
/*
* This is invoked from the main JavaScript thread.
* V8 context is available.
*/
......@@ -89,7 +89,7 @@ template <typename T, typename L>
T CallbackBridge<T, L>::operator()(std::vector<void*> argv) {
// argv.push_back(wrapper);
if (this->is_sync) {
/*
/*
* This is invoked from the main JavaScript thread.
* V8 context is available.
*
......@@ -110,7 +110,7 @@ T CallbackBridge<T, L>::operator()(std::vector<void*> argv) {
this->callback->Call(argv_v8.size(), &argv_v8[0])
);
} else {
/*
/*
* This is invoked from the worker thread.
* No V8 context and functions available.
* Just wait for response from asynchronously
......@@ -141,7 +141,7 @@ template <typename T, typename L>
void CallbackBridge<T, L>::dispatched_async_uv_callback(uv_async_t *req) {
CallbackBridge* bridge = static_cast<CallbackBridge*>(req->data);
/*
/*
* Function scheduled via uv_async mechanism, therefore
* it is invoked from the main JavaScript thread.
* V8 context is available.
......@@ -169,7 +169,7 @@ void CallbackBridge<T, L>::dispatched_async_uv_callback(uv_async_t *req) {
template <typename T, typename L>
NAN_METHOD(CallbackBridge<T COMMA L>::ReturnCallback) {
/*
/*
* Callback function invoked by the user code.
* It is invoked from the main JavaScript thread.
* V8 context is available.
......
......@@ -29,6 +29,7 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
imports[i] = sass_make_import_entry(0, 0, 0);
sass_import_set_error(imports[i], message, -1, -1);
free(message);
}
else {
imports[i] = get_importer_entry(object);
......@@ -43,6 +44,7 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
imports[0] = sass_make_import_entry(0, 0, 0);
sass_import_set_error(imports[0], message, -1, -1);
free(message);
}
else if (returned_value->IsObject()) {
imports = sass_make_import_list(1);
......@@ -55,12 +57,12 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
Sass_Import* CustomImporterBridge::check_returned_string(Nan::MaybeLocal<v8::Value> value, const char *msg) const
{
v8::Local<v8::Value> checked;
if (value.ToLocal(&checked)) {
if (value.ToLocal(&checked)) {
if (!checked->IsUndefined() && !checked->IsString()) {
goto err;
} else {
return nullptr;
}
}
}
err:
auto entry = sass_make_import_entry(0, 0, 0);
......
......@@ -23,6 +23,10 @@ namespace SassTypes
}
unit = create_string(raw_val[1]);
*out = sass_make_number(value, unit);
delete unit;
return *out;
}
}
......
......@@ -15,9 +15,14 @@ namespace SassTypes
}
value = create_string(raw_val[0]);
*out = sass_make_string(value);
delete value;
return *out;
} else {
return *out = sass_make_string(value);
}
return *out = sass_make_string(value);
}
void String::initPrototype(v8::Local<v8::FunctionTemplate> proto) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment