some frontend adjustments
[pcsx_rearmed.git] / frontend / common / menu.c
index ae1ff57..aa76e43 100644 (file)
@@ -1,7 +1,12 @@
-// (c) Copyright 2006-2010 notaz, All rights reserved.\r
-// Free for non-commercial use.\r
-\r
-// For commercial use, separate licencing terms must be obtained.\r
+/*\r
+ * (C) GraÅžvydas "notaz" Ignotas, 2006-2010\r
+ *\r
+ * This work is licensed under the terms of any of these licenses\r
+ * (at your option):\r
+ *  - GNU GPL, version 2 or later.\r
+ *  - GNU LGPL, version 2.1 or later.\r
+ * See the COPYING file in the top-level directory.\r
+ */\r
 \r
 #include <stdio.h>\r
 #include <string.h>\r
@@ -867,9 +872,12 @@ rescan:
                        {\r
                                int newlen;\r
                                char *p, *newdir;\r
-                               if (!(inp & PBTN_MOK)) continue;\r
+                               if (!(inp & PBTN_MOK))\r
+                                       continue;\r
                                newlen = strlen(curr_path) + strlen(namelist[sel+1]->d_name) + 2;\r
                                newdir = malloc(newlen);\r
+                               if (newdir == NULL)\r
+                                       break;\r
                                if (strcmp(namelist[sel+1]->d_name, "..") == 0) {\r
                                        char *start = curr_path;\r
                                        p = start + strlen(start) - 1;\r
@@ -915,6 +923,13 @@ rescan:
                free(namelist);\r
        }\r
 \r
+       // restore curr_path\r
+       if (fname != NULL) {\r
+               n = strlen(curr_path);\r
+               if (curr_path + n + 1 == fname)\r
+                       curr_path[n] = '/';\r
+       }\r
+\r
        return ret;\r
 }\r
 \r