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 23, 2023
1 parent 576e20d commit 2d96b60
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,34 @@ macro_rules! redis_module {
use $crate::configuration::get_bool_default_config_value;
use $crate::configuration::get_enum_default_config_value;

if ctx.is_null() {
$crate::logging::log_warning(
"The module context pointer is null."
);
return raw::Status::Err as _;
}

if argv.is_null() && argc != 0 {
$crate::logging::log_warning(
"The module argv is null but the argc is not zero."
);
return raw::Status::Err as _;
}

if !argv.is_null() && unsafe { (*argv).is_null() } {
$crate::logging::log_warning(
"The module argv is initialised but has no data."
);
return raw::Status::Err as _;
}

if !argv.is_null() && unsafe { !(*argv).is_null() } && (argc <= 0) {
$crate::logging::log_warning(
"Incorrect number of module arguments."
);
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 2d96b60

Please sign in to comment.