Prevent issue fix
authorAndrzej Surdej <a.surdej@samsung.com>
Tue, 19 Mar 2013 11:38:17 +0000 (12:38 +0100)
committerGerrit Code Review <gerrit2@kim11>
Mon, 25 Mar 2013 12:22:56 +0000 (21:22 +0900)
[Issue#] N/A
[Problem] tmpnam_r(NULL) returns NULL instead of string
[Cause] N/A
[Solution] changed to tmpnam
[Verification] Build repo. Current state was present before.

Change-Id: Ife262ccd3dad5750f1c4934d2ae2bc2772f1a7d7

src/wrt-popup/wrt/popup-runner/PopupInvoker.cpp
src/wrt-popup/wrt/popup-runner/PopupInvoker.h

index 10997dc..28f32a1 100644 (file)
@@ -22,6 +22,7 @@
 #include <dpl/waitable_handle.h>
 #include <dpl/binary_queue.h>
 #include <dpl/serialization.h>
+#include <dpl/exception.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include "PopupEnum.h"
@@ -33,20 +34,20 @@ const char *POPUP_EXEC = "/usr/bin/wrt-popup-wrt-runtime";
 
 namespace Wrt {
 namespace Popup {
-PopupInvoker::PopupInvoker() :
-    m_inputName(tmpnam_r(NULL)),
-    m_outputName(tmpnam_r(NULL))
+PopupInvoker::PopupInvoker()
 {
-    Try
-    {
-        m_input.Create(m_inputName);
-        m_output.Create(m_outputName);
-        LogDebug("Pipes created");
-    }
-    Catch(DPL::Exception)
-    {
-        LogError("Cannot create pipes");
-    }
+    char tmp[L_tmpnam + 1];
+    if (NULL == tmpnam(tmp))
+        ThrowMsg(DPL::Exception, "Failed to get pipe name");
+    m_inputName = tmp;
+
+    if (NULL == tmpnam(tmp))
+        ThrowMsg(DPL::Exception, "Failed to get pipe name");
+    m_outputName = tmp;
+
+    m_input.Create(m_inputName);
+    m_output.Create(m_outputName);
+    LogDebug("Pipes created");
 }
 
 PopupInvoker::~PopupInvoker()
index 157640a..278db6d 100644 (file)
@@ -66,8 +66,8 @@ class PopupInvoker
 
     DPL::NamedInputPipe m_input;
     DPL::NamedOutputPipe m_output;
-    const std::string m_inputName;
-    const std::string m_outputName;
+    std::string m_inputName;
+    std::string m_outputName;
 };
 } // Popup
 } // Wrt