qt5_msgbox: check if message has only a newline character.
authorJihye Won <jihye.won1@samsung.com>
Tue, 13 Oct 2015 05:02:10 +0000 (14:02 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 14 Oct 2015 05:00:28 +0000 (14:00 +0900)
qt5_msgbox shows an empty message
when the message as the argument of error_report() ends a newline character.
So, it is necessary to check if the message is valid before executing qt5_msgbox.

Change-Id: I48e4bd0e484a69bd00c6a9aace5b4390d996bd62
Signed-off-by: Jihye Won <jihye.won1@samsung.com>
tizen/src/util/qt5_error_report.c

index d9f3c868c15675052f14b83f735220728aa9b8fb..dacc5a1614720e05ef40a32c75f000333c0e8c32 100644 (file)
@@ -40,6 +40,8 @@
 #include <process.h>
 #endif
 
+#define MAX_MESSAGE_LEN 2048
+
 MULTI_DEBUG_CHANNEL(qemu, qt5_msgbox);
 
 static const char * const icon_types[] = {
@@ -63,23 +65,36 @@ char *get_app_path(void)
 
 void start_qt5_msgbox(qt5_msgbox_icon icon, const char *message)
 {
+    INFO("qt5_msgbox starts... \n");
+
+    if (message[0] == '\n' && strnlen(message, MAX_MESSAGE_LEN) == 1) {
+        ERR("The message has only a new-line character. \n" );
+        return;
+    }
+
     char *app_path = get_app_path();
     const char *title = "Emulator";
     const char *argv[] = {app_path, icon_types[icon], title, message, NULL};
 
 #ifdef CONFIG_WIN32
-    INFO("qt5_msgbox starts... \n");
-    if (_spawnv(P_NOWAIT, app_path, (const char * const *) argv) == -1)
-        ERR("qt5_msgbox can not be executed \n");
+    if (_spawnv(P_NOWAIT, app_path, (const char * const *) argv) == -1) {
+        ERR("qt5_msgbox can not be executed. \n");
+        g_free(app_path);
+        return;
+    }
 #else
     pid_t child_pid = fork();
     if (child_pid == 0) {
-        INFO("qt5_msgbox starts... \n");
-        if(execvp(app_path, (char * const *) argv) == -1)
-            ERR("qt5_msgbox can not be executed \n");
+        if (execvp(app_path, (char * const *) argv) == -1) {
+            ERR("qt5_msgbox can not be executed. \n");
+            g_free(app_path);
+            return;
+        }
         exit(0);
     } else if (child_pid == -1) {
-        ERR("qt5_msgbox can not be executed \n");
+        ERR("child process for qt5_msgbox can not be created. \n");
+        g_free(app_path);
+        return;
     }
 #endif
     g_free(app_path);