fixed bug that may lead to free()ing static memory
[rocksndiamonds.git] / src / libgame / misc.c
index 3e7719e1da6a32292a6a1339784f5ed27024150e..3ff1f8aa9c269d18e84b4bcb8ecf9d806287acd3 100644 (file)
@@ -682,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;
 }
@@ -2922,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"))
   {