Skip to content

Commit

Permalink
Add checks for the module initialisation.
Browse files Browse the repository at this point in the history
This should fix the ASAN issues and possible issues at runtime.
  • Loading branch information
iddm committed May 22, 2023
1 parent b0939e7 commit b076313
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,22 @@ macro_rules! redis_module {
use $crate::configuration::get_bool_default_config_value;
use $crate::configuration::get_enum_default_config_value;

if ctx.is_null() {
return raw::Status::Err as _;
}

if argv.is_null() && argc != 0 {
return raw::Status::Err as _;
}

if !argv.is_null() && unsafe { (*argv).is_null() } {
return raw::Status::Err as _;
}

if !argv.is_null() && unsafe { !(*argv).is_null() } && argc.is_negative() {
return raw::Status::Err as _;
}

// We use a statically sized buffer to avoid allocating.
// This is needed since we use a custom allocator that relies on the Redis allocator,
// which isn't yet ready at this point.
Expand Down

0 comments on commit b076313

Please sign in to comment.