AntiPattern
Length Calculation Mismatch
length-calculation-mismatch
Buffer sizing logic uses a computed length that doesn’t match the actual write or returned data length, so copies/substrings or syscalls can exceed allocated bounds or underflow sizes, triggering memory corruption or crashes like stack exhaustion.