Mac and Linux SDL2 binary snapshots
Edward Rudd
2020-05-02 03f8528315fa46c95991a34f3325d7b33ae5538c
source/src/stdlib/SDL_iconv.c
@@ -1,6 +1,6 @@
/*
  Simple DirectMedia Layer
  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
@@ -37,7 +37,7 @@
   iconv() may or may not use const char ** for the inbuf param.
   If we get this wrong, it's just a warning, so no big deal.
*/
#if defined(_XGP6) || defined(__APPLE__) || \
#if defined(_XGP6) || defined(__APPLE__) || defined(__RISCOS__) || \
    defined(__EMSCRIPTEN__) || \
    (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) || \
    (defined(_NEWLIB_VERSION)))
@@ -888,7 +888,7 @@
    }
    stringsize = inbytesleft > 4 ? inbytesleft : 4;
    string = SDL_malloc(stringsize);
    string = (char *) SDL_malloc(stringsize);
    if (!string) {
        SDL_iconv_close(cd);
        return NULL;
@@ -898,13 +898,14 @@
    SDL_memset(outbuf, 0, 4);
    while (inbytesleft > 0) {
        const size_t oldinbytesleft = inbytesleft;
        retCode = SDL_iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
        switch (retCode) {
        case SDL_ICONV_E2BIG:
            {
                char *oldstring = string;
                stringsize *= 2;
                string = SDL_realloc(string, stringsize);
                string = (char *) SDL_realloc(string, stringsize);
                if (!string) {
                    SDL_iconv_close(cd);
                    return NULL;
@@ -925,6 +926,11 @@
            inbytesleft = 0;
            break;
        }
        /* Avoid infinite loops when nothing gets converted */
        if (oldinbytesleft == inbytesleft)
        {
            break;
        }
    }
    SDL_iconv_close(cd);