fixed bug that may lead to free()ing static memory
[rocksndiamonds.git] / src / libgame / misc.c
index bddd38d9a933ce858a53ee3d5c4706192107d35f..3ff1f8aa9c269d18e84b4bcb8ecf9d806287acd3 100644 (file)
@@ -571,7 +571,7 @@ char *getLoginName()
     if (GetUserName(login_name, &buffer_size) == 0)
       strcpy(login_name, ANONYMOUS_NAME);
   }
-#else
+#elif defined(PLATFORM_UNIX) && !defined(PLATFORM_ANDROID)
   if (login_name == NULL)
   {
     struct passwd *pwd;
@@ -581,6 +581,8 @@ char *getLoginName()
     else
       login_name = getStringCopy(pwd->pw_name);
   }
+#else
+  login_name = ANONYMOUS_NAME;
 #endif
 
   return login_name;
@@ -680,10 +682,16 @@ char *getBasePath(char *filename)
   char *basepath = getStringCopy(filename);
   char *last_separator = getLastPathSeparatorPtr(basepath);
 
-  if (last_separator != NULL)
-    *last_separator = '\0';    /* separator found: strip basename */
-  else
-    basepath = ".";            /* no separator found: use current path */
+  /* if no separator was found, use current directory */
+  if (last_separator == NULL)
+  {
+    free(basepath);
+
+    return getStringCopy(".");
+  }
+
+  /* separator found: strip basename */
+  *last_separator = '\0';
 
   return basepath;
 }
@@ -2920,6 +2928,9 @@ int get_parameter_value(char *value_raw, char *suffix, int type)
 
     if (string_has_parameter(value, "inner_corners"))
       result |= STYLE_INNER_CORNERS;
+
+    if (string_has_parameter(value, "reverse"))
+      result |= STYLE_REVERSE;
   }
   else if (strEqual(suffix, ".fade_mode"))
   {