Fixed crash if SDL_VideoDriverName() is passed a NULL namebuf
authorSam Lantinga <slouken@libsdl.org>
Thu, 03 Feb 2011 16:57:38 -0800
changeset 516788c656ffea44
parent 5166 4d39eeaad00b
child 5168 db487f28419e
Fixed crash if SDL_VideoDriverName() is passed a NULL namebuf
src/SDL_compat.c
     1.1 --- a/src/SDL_compat.c	Thu Feb 03 15:49:37 2011 -0800
     1.2 +++ b/src/SDL_compat.c	Thu Feb 03 16:57:38 2011 -0800
     1.3 @@ -57,8 +57,12 @@
     1.4  {
     1.5      const char *name = SDL_GetCurrentVideoDriver();
     1.6      if (name) {
     1.7 -        SDL_strlcpy(namebuf, name, maxlen);
     1.8 -        return namebuf;
     1.9 +        if (namebuf) {
    1.10 +            SDL_strlcpy(namebuf, name, maxlen);
    1.11 +            return namebuf;
    1.12 +        } else {
    1.13 +            return name;
    1.14 +        }
    1.15      }
    1.16      return NULL;
    1.17  }