Fixed crash if SDL_VideoDriverName() is passed a NULL namebuf
authorSam Lantinga <slouken@libsdl.org>
Thu, 03 Feb 2011 16:57:38 -0800
changeset 5167 88c656ffea44
parent 5166 4d39eeaad00b
child 5168 db487f28419e
Fixed crash if SDL_VideoDriverName() is passed a NULL namebuf
src/SDL_compat.c
--- a/src/SDL_compat.c	Thu Feb 03 15:49:37 2011 -0800
+++ b/src/SDL_compat.c	Thu Feb 03 16:57:38 2011 -0800
@@ -57,8 +57,12 @@
 {
     const char *name = SDL_GetCurrentVideoDriver();
     if (name) {
-        SDL_strlcpy(namebuf, name, maxlen);
-        return namebuf;
+        if (namebuf) {
+            SDL_strlcpy(namebuf, name, maxlen);
+            return namebuf;
+        } else {
+            return name;
+        }
     }
     return NULL;
 }