From 7f6eb0f51bd4e79ef5b4f1219fa81cf3e52d2512 Mon Sep 17 00:00:00 2001 From: Junkyeong Kim Date: Tue, 29 Dec 2020 16:57:25 +0900 Subject: [PATCH] e_info_server: add null checking in _e_info_server_cb_screen_dump_cb Change-Id: I78e446544c0dd9235396966ab9c15130f73c8fec Signed-off-by: Junkyeong Kim --- src/bin/e_info_server.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/bin/e_info_server.c b/src/bin/e_info_server.c index 0e4b72d9ac..f693f7c851 100644 --- a/src/bin/e_info_server.c +++ b/src/bin/e_info_server.c @@ -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 * -- 2.34.1