From 045cc52c1f0222b2950e2053d4e0504b547535e9 Mon Sep 17 00:00:00 2001 From: Malavan Sotheeswaran Date: Tue, 14 Feb 2023 18:23:35 -0800 Subject: [PATCH] don't use sizeof on malloc'd pointer --- src/modules/hellotimer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/hellotimer.c b/src/modules/hellotimer.c index 0d84ea647..4afc67967 100644 --- a/src/modules/hellotimer.c +++ b/src/modules/hellotimer.c @@ -51,8 +51,9 @@ int TimerCommand_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int for (int j = 0; j < 10; j++) { int delay = rand() % 5000; - char *buf = RedisModule_Alloc(256); - snprintf(buf,sizeof(buf),"After %d", delay); + int bufsize = 256; + char *buf = RedisModule_Alloc(bufsize); + snprintf(buf,bufsize,"After %d", delay); RedisModuleTimerID tid = RedisModule_CreateTimer(ctx,delay,timerHandler,buf); REDISMODULE_NOT_USED(tid); }