Windows: Fix heap overflow setting native icon

Fixes #71697.

(cherry picked from commit 86945ffc78)
This commit is contained in:
Jordan Schidlowsky 2023-01-19 15:32:00 -06:00 committed by Rémi Verschelde
parent 4500b3cd30
commit dc0f7255f1
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 1 additions and 1 deletions

View File

@ -3057,7 +3057,7 @@ void OS_Windows::set_native_icon(const String &p_filename) {
pos += sizeof(WORD);
f->seek(pos);
icon_dir = (ICONDIR *)memrealloc(icon_dir, 3 * sizeof(WORD) + icon_dir->idCount * sizeof(ICONDIRENTRY));
icon_dir = (ICONDIR *)memrealloc(icon_dir, sizeof(ICONDIR) + (icon_dir->idCount * sizeof(ICONDIRENTRY)));
f->get_buffer((uint8_t *)&icon_dir->idEntries[0], icon_dir->idCount * sizeof(ICONDIRENTRY));
int small_icon_index = -1; // Select 16x16 with largest color count