e_info_server: add null checking in _e_info_server_cb_screen_dump_cb 41/250541/3
authorJunkyeong Kim <jk0430.kim@samsung.com>
Tue, 29 Dec 2020 07:57:25 +0000 (16:57 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 29 Dec 2020 08:10:23 +0000 (08:10 +0000)
Change-Id: I78e446544c0dd9235396966ab9c15130f73c8fec
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/bin/e_info_server.c

index 0e4b72d..f693f7c 100644 (file)
@@ -4695,7 +4695,15 @@ _e_info_server_cb_screen_dump_cb(E_Output *eout, tbm_surface_h surface, void *us
    char *slash, *dot;
    int dlen = 0, flen = 0;
 
+   EINA_SAFETY_ON_NULL_GOTO(surface, done);
+   EINA_SAFETY_ON_NULL_GOTO(path, done);
+
    slash = strrchr(path, '/');
+   if (slash == NULL)
+     {
+        ERR("cannot find /");
+        goto done;
+     }
    slash += 1;
 
    dlen = strnlen(path, PATH_MAX) - strnlen(slash, PATH_MAX);
@@ -4708,6 +4716,11 @@ _e_info_server_cb_screen_dump_cb(E_Output *eout, tbm_surface_h surface, void *us
    dir[dlen] = '\0';
 
    dot = strrchr(path, '.');
+   if (dot == NULL)
+     {
+        ERR("cannot find .");
+        goto done;
+     }
 
    flen = strnlen(slash, PATH_MAX) - strnlen(dot, PATH_MAX);
    if (flen <= 0)
@@ -4727,8 +4740,10 @@ _e_info_server_cb_screen_dump_cb(E_Output *eout, tbm_surface_h surface, void *us
    DBG("_e_info_server_cb_screen_dump_cb done");
 
 done:
-   free(path);
-   tbm_surface_destroy(surface);
+   if (path != NULL)
+     free(path);
+   if (surface != NULL)
+     tbm_surface_destroy(surface);
 }
 
 static Eldbus_Message *