From bc9c86bcc2470f018a5b8ec1920dd45505757f63 Mon Sep 17 00:00:00 2001
From: Semphris <[EMAIL REDACTED]>
Date: Tue, 17 Dec 2024 22:52:26 -0500
Subject: [PATCH] Dialog: Add suffix to filters all the time
For some obscure reason I can't remember, I had made it so the suffix would be added only if the filter list was empty. That isn't the expected behavior and caused a mishandling of memory on Windows, which requires a two-null-bytes suffix.
---
src/dialog/SDL_dialog_utils.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/src/dialog/SDL_dialog_utils.c b/src/dialog/SDL_dialog_utils.c
index ef3fbdf297641..38be4a1174f38 100644
--- a/src/dialog/SDL_dialog_utils.c
+++ b/src/dialog/SDL_dialog_utils.c
@@ -78,21 +78,18 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
SDL_free(converted);
}
- // If the filter list is empty, put the suffix
- if (!filters->name || !filters->pattern) {
- new_length = SDL_strlen(combined) + SDL_strlen(suffix) + 1;
+ new_length = SDL_strlen(combined) + SDL_strlen(suffix) + 1;
- new_combined = (char *)SDL_realloc(combined, new_length);
+ new_combined = (char *)SDL_realloc(combined, new_length);
- if (!new_combined) {
- SDL_free(combined);
- return NULL;
- }
+ if (!new_combined) {
+ SDL_free(combined);
+ return NULL;
+ }
- combined = new_combined;
+ combined = new_combined;
- SDL_strlcat(combined, suffix, new_length);
- }
+ SDL_strlcat(combined, suffix, new_length);
return combined;
}