mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 17:06:25 +00:00
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.
This commit is contained in:
@@ -78,22 +78,19 @@ char *convert_filters(const SDL_DialogFileFilter *filters, int nfilters,
|
|||||||
SDL_free(converted);
|
SDL_free(converted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the filter list is empty, put the suffix
|
new_length = SDL_strlen(combined) + SDL_strlen(suffix) + 1;
|
||||||
if (!filters->name || !filters->pattern) {
|
|
||||||
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) {
|
if (!new_combined) {
|
||||||
SDL_free(combined);
|
SDL_free(combined);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
combined = new_combined;
|
|
||||||
|
|
||||||
SDL_strlcat(combined, suffix, new_length);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
combined = new_combined;
|
||||||
|
|
||||||
|
SDL_strlcat(combined, suffix, new_length);
|
||||||
|
|
||||||
return combined;
|
return combined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user