Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
3052263f
Commit
3052263f
authored
Oct 31, 2017
by
Stefan Penner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LEAK FIX] create_string must be paired with a free
parent
4cf43ac9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
10 deletions
+24
-10
binding.cpp
src/binding.cpp
+5
-2
callback_bridge.h
src/callback_bridge.h
+5
-5
custom_importer_bridge.cpp
src/custom_importer_bridge.cpp
+4
-2
number.cpp
src/sass_types/number.cpp
+4
-0
string.cpp
src/sass_types/string.cpp
+6
-1
No files found.
src/binding.cpp
View file @
3052263f
...
@@ -158,7 +158,9 @@ int ExtractOptions(v8::Local<v8::Object> options, void* cptr, sass_context_wrapp
...
@@ -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
);
CustomFunctionBridge
*
bridge
=
new
CustomFunctionBridge
(
callback
,
ctx_w
->
is_sync
);
ctx_w
->
function_bridges
.
push_back
(
bridge
);
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
);
sass_function_set_list_entry
(
fn_list
,
i
,
fn
);
}
}
...
@@ -267,7 +269,7 @@ NAN_METHOD(render) {
...
@@ -267,7 +269,7 @@ NAN_METHOD(render) {
struct
Sass_Data_Context
*
dctx
=
sass_make_data_context
(
source_string
);
struct
Sass_Data_Context
*
dctx
=
sass_make_data_context
(
source_string
);
sass_context_wrapper
*
ctx_w
=
sass_make_context_wrapper
();
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
);
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) {
...
@@ -290,6 +292,7 @@ NAN_METHOD(render_sync) {
}
}
sass_free_context_wrapper
(
ctx_w
);
sass_free_context_wrapper
(
ctx_w
);
info
.
GetReturnValue
().
Set
(
result
==
0
);
info
.
GetReturnValue
().
Set
(
result
==
0
);
}
}
...
...
src/callback_bridge.h
View file @
3052263f
...
@@ -55,7 +55,7 @@ Nan::Persistent<v8::Function> CallbackBridge<T, L>::wrapper_constructor;
...
@@ -55,7 +55,7 @@ Nan::Persistent<v8::Function> CallbackBridge<T, L>::wrapper_constructor;
template
<
typename
T
,
typename
L
>
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
)
{
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.
* This is invoked from the main JavaScript thread.
* V8 context is available.
* V8 context is available.
*/
*/
...
@@ -89,7 +89,7 @@ template <typename T, typename L>
...
@@ -89,7 +89,7 @@ template <typename T, typename L>
T
CallbackBridge
<
T
,
L
>::
operator
()(
std
::
vector
<
void
*>
argv
)
{
T
CallbackBridge
<
T
,
L
>::
operator
()(
std
::
vector
<
void
*>
argv
)
{
// argv.push_back(wrapper);
// argv.push_back(wrapper);
if
(
this
->
is_sync
)
{
if
(
this
->
is_sync
)
{
/*
/*
* This is invoked from the main JavaScript thread.
* This is invoked from the main JavaScript thread.
* V8 context is available.
* V8 context is available.
*
*
...
@@ -110,7 +110,7 @@ T CallbackBridge<T, L>::operator()(std::vector<void*> argv) {
...
@@ -110,7 +110,7 @@ T CallbackBridge<T, L>::operator()(std::vector<void*> argv) {
this
->
callback
->
Call
(
argv_v8
.
size
(),
&
argv_v8
[
0
])
this
->
callback
->
Call
(
argv_v8
.
size
(),
&
argv_v8
[
0
])
);
);
}
else
{
}
else
{
/*
/*
* This is invoked from the worker thread.
* This is invoked from the worker thread.
* No V8 context and functions available.
* No V8 context and functions available.
* Just wait for response from asynchronously
* Just wait for response from asynchronously
...
@@ -141,7 +141,7 @@ template <typename T, typename L>
...
@@ -141,7 +141,7 @@ template <typename T, typename L>
void
CallbackBridge
<
T
,
L
>::
dispatched_async_uv_callback
(
uv_async_t
*
req
)
{
void
CallbackBridge
<
T
,
L
>::
dispatched_async_uv_callback
(
uv_async_t
*
req
)
{
CallbackBridge
*
bridge
=
static_cast
<
CallbackBridge
*>
(
req
->
data
);
CallbackBridge
*
bridge
=
static_cast
<
CallbackBridge
*>
(
req
->
data
);
/*
/*
* Function scheduled via uv_async mechanism, therefore
* Function scheduled via uv_async mechanism, therefore
* it is invoked from the main JavaScript thread.
* it is invoked from the main JavaScript thread.
* V8 context is available.
* V8 context is available.
...
@@ -169,7 +169,7 @@ void CallbackBridge<T, L>::dispatched_async_uv_callback(uv_async_t *req) {
...
@@ -169,7 +169,7 @@ void CallbackBridge<T, L>::dispatched_async_uv_callback(uv_async_t *req) {
template
<
typename
T
,
typename
L
>
template
<
typename
T
,
typename
L
>
NAN_METHOD
(
CallbackBridge
<
T
COMMA
L
>::
ReturnCallback
)
{
NAN_METHOD
(
CallbackBridge
<
T
COMMA
L
>::
ReturnCallback
)
{
/*
/*
* Callback function invoked by the user code.
* Callback function invoked by the user code.
* It is invoked from the main JavaScript thread.
* It is invoked from the main JavaScript thread.
* V8 context is available.
* V8 context is available.
...
...
src/custom_importer_bridge.cpp
View file @
3052263f
...
@@ -29,6 +29,7 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
...
@@ -29,6 +29,7 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
imports
[
i
]
=
sass_make_import_entry
(
0
,
0
,
0
);
imports
[
i
]
=
sass_make_import_entry
(
0
,
0
,
0
);
sass_import_set_error
(
imports
[
i
],
message
,
-
1
,
-
1
);
sass_import_set_error
(
imports
[
i
],
message
,
-
1
,
-
1
);
free
(
message
);
}
}
else
{
else
{
imports
[
i
]
=
get_importer_entry
(
object
);
imports
[
i
]
=
get_importer_entry
(
object
);
...
@@ -43,6 +44,7 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
...
@@ -43,6 +44,7 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
imports
[
0
]
=
sass_make_import_entry
(
0
,
0
,
0
);
imports
[
0
]
=
sass_make_import_entry
(
0
,
0
,
0
);
sass_import_set_error
(
imports
[
0
],
message
,
-
1
,
-
1
);
sass_import_set_error
(
imports
[
0
],
message
,
-
1
,
-
1
);
free
(
message
);
}
}
else
if
(
returned_value
->
IsObject
())
{
else
if
(
returned_value
->
IsObject
())
{
imports
=
sass_make_import_list
(
1
);
imports
=
sass_make_import_list
(
1
);
...
@@ -55,12 +57,12 @@ SassImportList CustomImporterBridge::post_process_return_value(v8::Local<v8::Val
...
@@ -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
Sass_Import
*
CustomImporterBridge
::
check_returned_string
(
Nan
::
MaybeLocal
<
v8
::
Value
>
value
,
const
char
*
msg
)
const
{
{
v8
::
Local
<
v8
::
Value
>
checked
;
v8
::
Local
<
v8
::
Value
>
checked
;
if
(
value
.
ToLocal
(
&
checked
))
{
if
(
value
.
ToLocal
(
&
checked
))
{
if
(
!
checked
->
IsUndefined
()
&&
!
checked
->
IsString
())
{
if
(
!
checked
->
IsUndefined
()
&&
!
checked
->
IsString
())
{
goto
err
;
goto
err
;
}
else
{
}
else
{
return
nullptr
;
return
nullptr
;
}
}
}
}
err
:
err
:
auto
entry
=
sass_make_import_entry
(
0
,
0
,
0
);
auto
entry
=
sass_make_import_entry
(
0
,
0
,
0
);
...
...
src/sass_types/number.cpp
View file @
3052263f
...
@@ -23,6 +23,10 @@ namespace SassTypes
...
@@ -23,6 +23,10 @@ namespace SassTypes
}
}
unit
=
create_string
(
raw_val
[
1
]);
unit
=
create_string
(
raw_val
[
1
]);
*
out
=
sass_make_number
(
value
,
unit
);
delete
unit
;
return
*
out
;
}
}
}
}
...
...
src/sass_types/string.cpp
View file @
3052263f
...
@@ -15,9 +15,14 @@ namespace SassTypes
...
@@ -15,9 +15,14 @@ namespace SassTypes
}
}
value
=
create_string
(
raw_val
[
0
]);
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
)
{
void
String
::
initPrototype
(
v8
::
Local
<
v8
::
FunctionTemplate
>
proto
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment