Skip to content

Commit

Permalink
Fix bad memory accounting for sds when no malloc_size available
Browse files Browse the repository at this point in the history
Signed-off-by: ranshid <[email protected]>
  • Loading branch information
ranshid committed Jun 25, 2024
1 parent 4d3d6c0 commit 45ed952
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sds.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ size_t sdsAllocSize(sds s) {
char type = s[-1] & SDS_TYPE_MASK;
/* SDS_TYPE_5 header doesn't contain the size of the allocation */
if (type == SDS_TYPE_5) {
return s_malloc_size(sdsAllocPtr(s));
return s_malloc_usable_size(sdsAllocPtr(s));
} else {
return sdsHdrSize(type) + sdsalloc(s) + 1;
}
Expand Down
1 change: 1 addition & 0 deletions src/sdsalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@
#define s_trymalloc_usable ztrymalloc_usable
#define s_tryrealloc_usable ztryrealloc_usable
#define s_malloc_size zmalloc_size
#define s_malloc_usable_size zmalloc_usable_size

#endif

0 comments on commit 45ed952

Please sign in to comment.