Skip to content

Fix hscan return value#13297

Merged
tezc merged 2 commits intoredis:hash-field-expiry-integfrom
tezc:fix-scan
May 28, 2024
Merged

Fix hscan return value#13297
tezc merged 2 commits intoredis:hash-field-expiry-integfrom
tezc:fix-scan

Conversation

@tezc
Copy link
Copy Markdown
Collaborator

@tezc tezc commented May 28, 2024

127.0.0.1:6379> hset myhash1 a 11111111111111111111111111111111111111111111111111111111111111111
(integer) 0
127.0.0.1:6379> hscan myhash1 0
1) "0"
2) 1) "a"
   2) "11111111111111111111111111111111111111111111111111111111111111111\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

In the last step of hscan, while replying to client, we assume all items in the result list are keys which are mstr instances.
Though, there might be values which are sds instances.

Added a check to avoid calling mstrlen() for value objects.

@tezc tezc requested review from moticless and sundb May 28, 2024 06:19
Comment thread src/db.c Outdated
Comment thread tests/unit/scan.tcl Outdated
@tezc tezc merged commit 6a11d45 into redis:hash-field-expiry-integ May 28, 2024
@tezc tezc deleted the fix-scan branch April 8, 2025 21:06
funny-dog pushed a commit to funny-dog/redis that referenced this pull request Sep 17, 2025
In the last step of hscan, while replying to client, we assume all items
in the result list are keys which are mstr instances. Though, there 
might be values which are sds instances. 

Added a check to avoid calling mstrlen() for value objects.

To reproduce:
```
127.0.0.1:6379> hset myhash1 a 11111111111111111111111111111111111111111111111111111111111111111
(integer) 0
127.0.0.1:6379> hscan myhash1 0
1) "0"
2) 1) "a"
   2) "11111111111111111111111111111111111111111111111111111111111111111\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants