Skip to content

Fix Galois field operations and add reference counting for table init…#6

Merged
benoit-a merged 1 commit intodevelopment/1.0from
user/ff10/fix_gallois
Dec 18, 2025
Merged

Fix Galois field operations and add reference counting for table init…#6
benoit-a merged 1 commit intodevelopment/1.0from
user/ff10/fix_gallois

Conversation

@fferrandis
Copy link
Copy Markdown

…ialization

This commit addresses two important improvements to the RS Vandermonde implementation:

  1. Type safety fix in region_multiply():

    • Cast from_buf[i] to unsigned char before passing to rs_galois_mult()
    • Ensures correct behavior when processing signed char values in Galois field arithmetic operations
    • Applied to both XOR and non-XOR code paths
  2. Reference counting for Galois table initialization:

    • Add init_counter to track multiple initialization/deinitialization calls
    • Prevent double initialization of log_table and ilog_table
    • Implement proper reference counting in rs_galois_deinit_tables() to only free tables when all references are released
    • Set pointers to NULL after freeing to prevent use-after-free issues

These changes improve robustness and prevent potential crashes from improper table lifecycle management.

…ialization

This commit addresses two important improvements to the RS Vandermonde
implementation:

1. Type safety fix in region_multiply():
   - Cast from_buf[i] to unsigned char before passing to rs_galois_mult()
   - Ensures correct behavior when processing signed char values in
     Galois field arithmetic operations
   - Applied to both XOR and non-XOR code paths

2. Reference counting for Galois table initialization:
   - Add init_counter to track multiple initialization/deinitialization
     calls
   - Prevent double initialization of log_table and ilog_table
   - Implement proper reference counting in rs_galois_deinit_tables()
     to only free tables when all references are released
   - Set pointers to NULL after freeing to prevent use-after-free issues

These changes improve robustness and prevent potential crashes from
improper table lifecycle management.
@fferrandis
Copy link
Copy Markdown
Author

/approve

@benoit-a benoit-a merged commit 2dbc9b2 into development/1.0 Dec 18, 2025
1 check passed
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