Skip to content

Commit

Permalink
Add checks for the module initialisation.
Browse files Browse the repository at this point in the history
This should resolve the debug assertion and allow only safe code
to continue.
  • Loading branch information
iddm committed May 22, 2023
1 parent b0939e7 commit 500703a
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 <= 0) {
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 500703a

Please sign in to comment.