Browse Source

Don't use alloca() in a loop, we might overflow the stack.

Sam Lantinga 8 months ago
parent
commit
2c0fcf27e8
1 changed files with 2 additions and 3 deletions
  1. 2 3
      src/video/windows/SDL_windowswindow.c

+ 2 - 3
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);