Merge pull request #71699 from jordo/PR-windows-heap-overflow-fix

Windows: Fix heap overflow setting native icon
This commit is contained in:
Rémi Verschelde 2023-01-23 22:24:01 +01:00
commit 627d688c80
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -3105,7 +3105,7 @@ void OS_Windows::set_native_icon(const String &p_filename) {
pos += sizeof(WORD); pos += sizeof(WORD);
f->seek(pos); 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)); 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 int small_icon_index = -1; // Select 16x16 with largest color count