emulator: revert SDL_init() routes stdout and stderr in win32 03/23003/3
authorSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 16 Jun 2014 07:16:12 +0000 (16:16 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 16 Jun 2014 07:32:06 +0000 (16:32 +0900)
SDL_init() routes stdout and stderr to the respective files in win32. So we revert it.
Prevent NULL dereferencing in g_ascii_strtoull().

Change-Id: I0e540f83a7701968746310035a580eadd8160ce6
Signed-off-by: SeokYeon Hwang <syeon.hwang@samsung.com>
tizen/src/emulator.c

index 66919d3227b1c7a0b83b7c09f60b6d134ff3ba0e..c7efcc2313b3ddc30bd5a3b328731ad987692bd7 100644 (file)
@@ -303,6 +303,13 @@ static int emulator_main(int argc, char *argv[], char **envp)
     }
 #endif
 
+#ifdef CONFIG_WIN32
+    // SDL_init() routes stdout and stderr to the respective files in win32.
+    // So we revert it.
+    freopen("CON", "w", stdout);
+    freopen("CON", "w", stderr);
+#endif
+
     gchar *profile = NULL;
     int c = 0;
 
@@ -364,13 +371,18 @@ static int emulator_main(int argc, char *argv[], char **envp)
         char *resolution = get_variable("resolution");
         if (!resolution) {
             fprintf(stderr, "[resolution] is required.\n");
+            return -1;
         }
         char **splitted = g_strsplit(resolution, "x", 2);
         if (!splitted[0] || !splitted[1]) {
             fprintf(stderr, "resolution value [%s] is weird. Please use format \"WIDTHxHEIGHT\"\n", resolution);
+            g_strfreev(splitted);
+            return -1;
         }
-        set_emul_resolution(g_ascii_strtoull(splitted[0], NULL, 0),
+        else {
+            set_emul_resolution(g_ascii_strtoull(splitted[0], NULL, 0),
                             g_ascii_strtoull(splitted[1], NULL, 0));
+        }
         g_strfreev(splitted);
     }