ccextractor icon indicating copy to clipboard operation
ccextractor copied to clipboard

Replace static buffer with dynamic allocation in writercwtdata()

Open AhmedAlian7 opened this issue 10 months ago • 3 comments

Description

The writercwtdata() function in src/lib_ccx/output.c currently uses a static array for the cbbuffer variable. There's a TODO comment requesting to replace this with dynamic memory allocation using malloc.

File: src/lib_ccx/output.c
Line: ~156
Function: writercwtdata()

Current Implementation

static unsigned char cbbuffer[0xFFFF * 3]; // TODO: use malloc

Proposed Change

Replace the static array with dynamically allocated memory to:

  • Improve memory efficiency
  • Follow modern C best practices
  • Only allocate memory when the function is actually used

Benefits

  1. Memory is only allocated when needed
  2. Better resource management
  3. Maintains backward compatibility
  4. No change to external behavior

Implementation Plan

I'm working on a PR that will:

  1. Convert cbbuffer from static array to dynamically allocated pointer
  2. Allocate memory on first use of the function
  3. Add proper error handling for allocation failures
  4. Add debug logging for buffer allocation

AhmedAlian7 avatar Feb 04 '26 15:02 AhmedAlian7

Hi @alya, I see there's an open PR (#37663) for this but the issue is currently unassigned. Would it be helpful if I reviewed the current PR or tested the changes locally to help move this toward a merge? Happy to help however needed

ektedar225 avatar Feb 10 '26 21:02 ektedar225

@ektedar225 it's already merged on #2092

AhmedAlian7 avatar Feb 10 '26 21:02 AhmedAlian7

Hi! I would like to work on this issue if it’s available. Please let me know if I can proceed or if there are any specific guidelines I should follow. Thank you!

ananyaaa66 avatar Feb 23 '26 16:02 ananyaaa66