summaryrefslogtreecommitdiff
path: root/src/t_hash.c
diff options
context:
space:
mode:
authorchendianqiang <c.d_q@163.com>2022-08-28 16:33:41 +0800
committerGitHub <noreply@github.com>2022-08-28 11:33:41 +0300
commitbc7fe41e5857a0854d524e2a63a028e9394d2a5c (patch)
tree1191701153059b83e4f5216a655faaf236867aea /src/t_hash.c
parenta7da7473cbd791589b943f38dcb855404a872928 (diff)
downloadredis-bc7fe41e5857a0854d524e2a63a028e9394d2a5c.tar.gz
fix hincrbyfloat not to create a key if the new value is invalid (#11149)
Check the validity of the value before performing the create operation, prevents new data from being generated even if the request fails to execute. Co-authored-by: Oran Agra <oran@redislabs.com> Co-authored-by: chendianqiang <chendianqiang@meituan.com> Co-authored-by: Binbin <binloveplay1314@qq.com>
Diffstat (limited to 'src/t_hash.c')
-rw-r--r--src/t_hash.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/t_hash.c b/src/t_hash.c
index 63447a4c1..a2af438ae 100644
--- a/src/t_hash.c
+++ b/src/t_hash.c
@@ -666,6 +666,10 @@ void hincrbyfloatCommand(client *c) {
unsigned int vlen;
if (getLongDoubleFromObjectOrReply(c,c->argv[3],&incr,NULL) != C_OK) return;
+ if (isnan(incr) || isinf(incr)) {
+ addReplyError(c,"value is NaN or Infinity");
+ return;
+ }
if ((o = hashTypeLookupWriteOrCreate(c,c->argv[1])) == NULL) return;
if (hashTypeGetValue(o,c->argv[2]->ptr,&vstr,&vlen,&ll) == C_OK) {
if (vstr) {