McRogueFace/src/Common.h
John McCardle 87444c2fd0 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>
2026-01-11 20:26:04 -05:00

20 lines
477 B
C++

# pragma once
#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>
#include <fstream>
#include <sstream>
#include <algorithm>
// wstring<->string conversion
#include <locale>
#include <codecvt>
#include <filesystem>