HeightMap: add GRID_MAX limit and input validation
Fixes potential integer overflow and invalid input issues: - Add GRID_MAX constant (8192) to Common.h for global use - Validate HeightMap dimensions against GRID_MAX to prevent integer overflow in w*h calculations (65536*65536 = 0) - Add min > max validation for clamp() and normalize() - Add unit tests for all new validation cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c095be4b73
commit
87444c2fd0
3 changed files with 90 additions and 0 deletions
|
|
@ -2,6 +2,10 @@
|
|||
#include <SFML/Graphics.hpp>
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
// Maximum dimension for grids, layers, and heightmaps (8192x8192 = 256MB of float data)
|
||||
// Prevents integer overflow in size calculations and limits memory allocation
|
||||
constexpr int GRID_MAX = 8192;
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue