Skip to content

Over-allocation in MockRedisAdapter list functions using size_bytes() instead of size() #81

Description

@bigsamich

Description

In mock/MockRedisAdapter.hpp:62-64 and 93-95, the list mock functions use data.size_bytes() for the allocation count but allocate elements of type T:

int dataSize = data.size_bytes();   // size in BYTES
new T[dataSize],                    // allocates dataSize ELEMENTS (each sizeof(T) bytes)

This allocates sizeof(T) * size_bytes() total bytes instead of the intended amount.

Additionally, std::vector<T> does not have a .size_bytes() method (line 93), so the vector overload likely won't compile for most types.

Severity

Critical

Suggested Fix

Use data.size() instead of data.size_bytes() for the allocation count.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmust fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions