Removed the limit on the size of the SDL error message

Also added SDL_GetOriginalMemoryFunctions()

Fixes https://github.com/libsdl-org/SDL/issues/5795
This commit is contained in:
Sam Lantinga 2022-06-27 16:59:50 -07:00
parent f25b4b2774
commit cbd0187475
11 changed files with 126 additions and 16 deletions

View file

@ -31,12 +31,22 @@ SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
/* Ignore call if invalid format pointer was passed */
if (fmt != NULL) {
va_list ap;
int result;
SDL_error *error = SDL_GetErrBuf();
error->error = 1; /* mark error as valid */
va_start(ap, fmt);
SDL_vsnprintf(error->str, ERR_MAX_STRLEN, fmt, ap);
result = SDL_vsnprintf(error->str, error->len, fmt, ap);
if (result >= 0 && (size_t)result >= error->len && error->realloc_func) {
size_t len = (size_t)result + 1;
char *str = (char *)error->realloc_func(error->str, len);
if (str) {
error->str = str;
error->len = len;
SDL_vsnprintf(error->str, error->len, fmt, ap);
}
}
va_end(ap);
if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {