screenshot: Add null check for defending null-dereference 30/96530/2
authorJiwon Kim <jiwon177.kim@samsung.com>
Wed, 9 Nov 2016 08:15:35 +0000 (17:15 +0900)
committerJiwon Kim <jiwon177.kim@samsung.com>
Wed, 9 Nov 2016 08:23:02 +0000 (00:23 -0800)
issue step:
 1. efl_util_screenshot_initialize() failed.
 2. But user call efl_util_screenshot_take_tbm_surface() with NULL
 3. Null dereference in 1501 line

Change-Id: I1e88264b0cd6750a2b7ccd316d2f31ea547d5795

src/efl_util.c

index 4ad4c79..9d7f1a4 100644 (file)
@@ -1485,7 +1485,7 @@ efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
    Efl_Util_Wl_Output_Info *output;
    int ret = 0;
 
-   if (screenshot != g_screenshot)
+   if (!screenshot || (screenshot != g_screenshot))
      {
         set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
         return NULL;