Skip to content

Null pointer dereference in RedisCache::copyReadBuffer early-return path #82

Description

@bigsamich

Description

In RedisCache.hpp:114, the copyReadBuffer method dereferences pElementsCopied without a null check on the early-return path, even though the parameter defaults to nullptr:

RA_Time copyReadBuffer(std::span<Type> destBuffer, int firstIndexToCopy = 0, int* pElementsCopied = nullptr)
{
  // ...
  if (copySourceStart >= sourceBuffer.end()) {
    *pElementsCopied = 0;   // CRASH: pElementsCopied defaults to nullptr
    return RA_Time();
  }

Line 119 correctly checks for null, but this early-return path on line 114 does not.

Severity

High

Suggested Fix

Add a null check: if (pElementsCopied) *pElementsCopied = 0;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions