Skip to content

Commit a767011

Browse files
committed
fix(asan): only use slice::from_raw_parts if locals_query is not null
1 parent 75e1bcf commit a767011

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tags/src/c_lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ pub extern "C" fn ts_tagger_add_language(
8484
let tagger = unwrap_mut_ptr(this);
8585
let scope_name = unsafe { unwrap(CStr::from_ptr(scope_name).to_str()) };
8686
let tags_query = unsafe { slice::from_raw_parts(tags_query, tags_query_len as usize) };
87-
let locals_query = unsafe { slice::from_raw_parts(locals_query, locals_query_len as usize) };
87+
let locals_query = if locals_query != std::ptr::null() {
88+
unsafe { slice::from_raw_parts(locals_query, locals_query_len as usize) }
89+
} else {
90+
&[]
91+
};
8892
let tags_query = match str::from_utf8(tags_query) {
8993
Ok(e) => e,
9094
Err(_) => return TSTagsError::InvalidUtf8,

0 commit comments

Comments
 (0)