Fix prevent
authorHeeJu Kang <mobum.kang@samsung.com>
Thu, 9 May 2013 05:42:10 +0000 (14:42 +0900)
committerHeeJu Kang <mobum.kang@samsung.com>
Thu, 9 May 2013 05:42:10 +0000 (14:42 +0900)
Change-Id: I78aa43474e967c642b2952074dfb0a271b89da35
Signed-off-by: HeeJu Kang <mobum.kang@samsung.com>
src/FShell_AppWidgetViewManager.cpp

index 0f013d1..11e8a13 100644 (file)
@@ -142,6 +142,14 @@ dump_bmp(const char* pFileName, const void* pData, int width, int height)
        fclose(pFile);
 }
 
+struct _Deleter
+{
+       void operator()(char* pStr)
+       {
+               free(pStr);
+       }
+};
+
 tbm_bufmgr
 bufmgr_get(Display* pDisplay, Pixmap pixmap)
 {
@@ -164,21 +172,22 @@ bufmgr_get(Display* pDisplay, Pixmap pixmap)
                return null;
        }
 
-       char* pDriverName = null;
-       char* pDeviceName = null;
-       if (!DRI2Connect(pDisplay, RootWindow(pDisplay, screen), &pDriverName, &pDeviceName))
+       char* pDriverNameTemp = null;
+       char* pDeviceNameTemp = null;
+       if (!DRI2Connect(pDisplay, RootWindow(pDisplay, screen), &pDriverNameTemp, &pDeviceNameTemp))
        {
                SysSecureLog(NID_UI_CTRL, "Failed to get value of DRI2Connect.");
                return null;
        }
 
-       SysSecureLog(NID_UI_CTRL, "The current name of open drm device is %s.", pDeviceName);
+       unique_ptr<char, _Deleter> pDriverName(pDriverNameTemp);
+       unique_ptr<char, _Deleter> pDeviceName(pDeviceNameTemp);
 
        // Get the drm_fd though opening the deviceName
-       __drmFileDescriptor = open(pDeviceName, O_RDWR);
+       __drmFileDescriptor = open(pDeviceName.get(), O_RDWR);
        if (__drmFileDescriptor < 0)
        {
-               SysSecureLog(NID_UI_CTRL, "Failed to open drm device (%s)", pDeviceName);
+               SysSecureLog(NID_UI_CTRL, "Failed to open drm device (%s)", pDeviceName.get());
                return null;
        }
 
@@ -220,14 +229,13 @@ pixmap_update(Display* pDisplay, tbm_bufmgr bufmgr, Pixmap pixmap, int x, int y,
        int opt = TBM_OPTION_READ|TBM_OPTION_WRITE;
        char imgFile[100] = {0,};
 
-       tbm_bo bo;
-       tbm_bo_handle bo_handle;
-
        DRI2Buffer* pDri2_buffers = DRI2GetBuffers (pDisplay, pixmap, &dri2_width, &dri2_height, attachments, dri2_count, &dri2_out_count);
-       SysTryLogCatch(NID_UI_CTRL, pDri2_buffers != null, , "Failed to get buffers.");
-       SysTryLogCatch(NID_UI_CTRL, pDri2_buffers[0].name != null, , "Failed to get a handle of the dri2 buffer.");
+       SysTryReturnVoidResult(NID_SHELL, pDri2_buffers != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
+       SysTryReturnVoidResult(NID_SHELL, pDri2_buffers[0].name != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
 
-       SysSecureLog(NID_UI_CTRL, "The current name of Dri2_buffers[0] is %d.", pDri2_buffers[0].name);
+       tbm_bo bo = null;
+       tbm_bo_handle bo_handle;
+       bo_handle.ptr = null;
 
        bo = tbm_bo_import(bufmgr, pDri2_buffers[0].name);
        SysTryLogCatch(NID_UI_CTRL, bo != null, , "Failed to import bo (key : %d).", pDri2_buffers[0].name);