From 2c0fcf27e8ee696d27630cea3bd82e538650149b Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 2 Aug 2024 21:33:42 -0700
Subject: [PATCH] Don't use alloca() in a loop, we might overflow the stack.
---
src/video/windows/SDL_windowswindow.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index c0f3692f192d0..c15e40ca08a75 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -2091,9 +2091,8 @@ static STDMETHODIMP SDLDropTarget_Drop(SDLDropTarget *target,
fetc.cfFormat, format_mime, (unsigned long)bsize, drop);
UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0);
for (UINT i = 0; i < count; ++i) {
- SDL_bool isstack;
UINT size = DragQueryFile(drop, i, NULL, 0) + 1;
- LPTSTR buffer = SDL_small_alloc(TCHAR, size, &isstack);
+ LPTSTR buffer = (LPTSTR)SDL_malloc(size * sizeof(TCHAR));
if (buffer) {
if (DragQueryFile(drop, i, buffer, size)) {
char *file = WIN_StringToUTF8(buffer);
@@ -2103,7 +2102,7 @@ static STDMETHODIMP SDLDropTarget_Drop(SDLDropTarget *target,
SDL_SendDropFile(target->window, NULL, file);
SDL_free(file);
}
- SDL_small_free(buffer, isstack);
+ SDL_free(buffer);
}
}
GlobalUnlock(med.hGlobal);