Fix #2062 Be more diligent about validating trailing "/" existence in HOME and XDG_DATA_HOME env vars
authorEdward Rudd <urkle@outoforder.cc>
Sat, 24 Aug 2013 09:05:18 -0400
changeset 7695 47d12c248988
parent 7694 7f965b1a24e0
child 7696 e605ca133ac6
Fix #2062 Be more diligent about validating trailing "/" existence in HOME and XDG_DATA_HOME env vars
src/filesystem/unix/SDL_sysfilesystem.c
--- a/src/filesystem/unix/SDL_sysfilesystem.c	Fri Aug 23 23:34:23 2013 -0400
+++ b/src/filesystem/unix/SDL_sysfilesystem.c	Sat Aug 24 09:05:18 2013 -0400
@@ -173,7 +173,15 @@
             SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
             return NULL;
         }
-        append = ".local/share/";
+        if (envr[SDL_strlen(envr) - 1] == '/') {
+            append = ".local/share/";
+        } else {
+            append = "/.local/share/";
+        }
+    } else {
+        if (envr[SDL_strlen(envr) - 1] == '/') {
+            append = "";
+        }
     } /* if */
 
     len = SDL_strlen(envr) + SDL_strlen(append) + SDL_strlen(app) + 2;