jmestwa-coder opened a new pull request, #688:
URL: https://github.com/apache/logging-log4cxx/pull/688

   ## Summary
   
   Centralize overflow-safe layout sizing and reservation logic across layout 
implementations.
   
   ## Changes
   
   - Added shared internal helpers in `layout_priv.h` for:
     - saturating layout size doubling
     - guarded reserve sizing validation
   
   - Replaced unchecked sizing arithmetic in:
     - `FMTLayout`
     - `HTMLLayout`
     - `JSONLayout`
     - `PatternLayout`
     - `XMLLayout`
   
   - Replaced direct sizing operations such as:
   
   ```cpp
   expectedPatternLength * 2
   output.reserve(a + b)
   ```
   
   with centralized checked helpers.
   
   ## Why
   
   The previous layout sizing logic used unchecked `size_t` arithmetic during:
   - expected buffer growth calculation
   - reserve size computation
   
   This change avoids invalid reserve calculations and overflow-prone sizing 
behavior while preserving existing formatting semantics.
   
   ## Behavior
   
   - No formatting or output changes
   - No parser or layout behavior changes
   - Only affects preallocation sizing paths
   - Falls back to normal append growth when reservation would exceed valid 
bounds
   
   ## Tests
   
   Added deterministic coverage for:
   - saturation behavior
   - boundary arithmetic cases
   - successful reserve paths
   - overflow/skip reserve paths
   
   Validated with focused `jsonlayouttest` coverage.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to