Skip to content

Commit 778b4b7

Browse files
committed
Add test to catch aux_save2 context leak
Signed-off-by: Jacob Murphy <[email protected]>
1 parent 73696bf commit 778b4b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/modules/testrdb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ void *testrdb_type_load(ValkeyModuleIO *rdb, int encver) {
7272
ValkeyModuleString *str = ValkeyModule_LoadString(rdb);
7373
float f = ValkeyModule_LoadFloat(rdb);
7474
long double ld = ValkeyModule_LoadLongDouble(rdb);
75+
ValkeyModuleCtx *ctx = ValkeyModule_GetContextFromIO(rdb);
7576
if (ValkeyModule_IsIOError(rdb)) {
76-
ValkeyModuleCtx *ctx = ValkeyModule_GetContextFromIO(rdb);
7777
if (str)
7878
ValkeyModule_FreeString(ctx, str);
7979
return NULL;
@@ -98,6 +98,8 @@ void testrdb_aux_save(ValkeyModuleIO *rdb, int when) {
9898
if (!(conf_aux_count & CONF_AUX_OPTION_BEFORE_KEYSPACE)) assert(when == VALKEYMODULE_AUX_AFTER_RDB);
9999
if (!(conf_aux_count & CONF_AUX_OPTION_AFTER_KEYSPACE)) assert(when == VALKEYMODULE_AUX_BEFORE_RDB);
100100
assert(conf_aux_count!=CONF_AUX_OPTION_NO_AUX);
101+
ValkeyModuleCtx *ctx = ValkeyModule_GetContextFromIO(rdb);
102+
VALKEYMODULE_NOT_USED(ctx);
101103
if (when == VALKEYMODULE_AUX_BEFORE_RDB) {
102104
if (before_str) {
103105
ValkeyModule_SaveSigned(rdb, 1);

0 commit comments

Comments
 (0)