Skip to content

Fix element-size typos in ExtendLayerBuffer allocations - #4039

Open
ManoharPaturi wants to merge 1 commit into
cisco:masterfrom
ManoharPaturi:fix-extend-layer-buffer-sizeof
Open

ManoharPaturi wants to merge 1 commit into
cisco:masterfrom
ManoharPaturi:fix-extend-layer-buffer-sizeof

Conversation

@ManoharPaturi

Copy link
Copy Markdown

Problem

Two allocation sites in ExtendLayerBuffer() use sizeof(int32_t*) where they mean sizeof(int32_t) (svc/encode_slice.cpp):

pFirstMbIdxOfSlice = (int32_t*)pMA->WelsMallocz (sizeof (int32_t*) * kiMaxSliceNumNew, ...);
pCountMbNumInSlice = (int32_t*)pMA->WelsMallocz (sizeof (int32_t*) * kiMaxSliceNumNew, ...);

On 64-bit hosts this allocates twice the needed size; the subsequent memset/memcpy use the correct element size, so behavior is safe but wastes 2× memory per reallocation.

Fix

Use the element type in both allocations.

Verification

Compiles clean; behavior identical (allocation shrinks to the correct size).

Copilot AI balanced review requested due to automatic review settings September 29, 2026 16:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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