Skip to content

Commit b076313

Browse files
committed
Add checks for the module initialisation.
This should fix the ASAN issues and possible issues at runtime.
1 parent b0939e7 commit b076313

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/macros.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,22 @@ macro_rules! redis_module {
190190
use $crate::configuration::get_bool_default_config_value;
191191
use $crate::configuration::get_enum_default_config_value;
192192

193+
if ctx.is_null() {
194+
return raw::Status::Err as _;
195+
}
196+
197+
if argv.is_null() && argc != 0 {
198+
return raw::Status::Err as _;
199+
}
200+
201+
if !argv.is_null() && unsafe { (*argv).is_null() } {
202+
return raw::Status::Err as _;
203+
}
204+
205+
if !argv.is_null() && unsafe { !(*argv).is_null() } && argc.is_negative() {
206+
return raw::Status::Err as _;
207+
}
208+
193209
// We use a statically sized buffer to avoid allocating.
194210
// This is needed since we use a custom allocator that relies on the Redis allocator,
195211
// which isn't yet ready at this point.

0 commit comments

Comments
 (0)