tbm_module: check the bufmgr_func symbol at tbm_module_bufmgr_get_capabilities 87/259887/1
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 15 Jun 2021 04:20:42 +0000 (13:20 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Tue, 15 Jun 2021 12:03:10 +0000 (21:03 +0900)
This avoids a crash when the bufmgr_funcs does not have a symbol.

Change-Id: I27109d06403d974629badf17bc6ed8eb49cfd6cb

src/tbm_module.c

index 1df44a8..d561406 100644 (file)
@@ -461,6 +461,7 @@ int
 tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error)
 {
        int capabilities = 0;
+       tbm_backend_bufmgr_func *bufmgr_func = NULL;
 
        TBM_RETURN_VAL_SET_ERR_IF_FAIL(module, TBM_BUFMGR_CAPABILITY_NONE, *error, TBM_ERROR_INVALID_PARAMETER);
 
@@ -469,11 +470,16 @@ tbm_module_bufmgr_get_capabilities(tbm_module *module, tbm_error_e *error)
                capabilities = hal_tbm_bufmgr_get_capabilities(module->hal_bufmgr, (hal_tbm_error *)error);
                break;
        case TBM_MODULE_TYPE_TBM_BACKEND:
+               bufmgr_func = module->bufmgr_func;
+               TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func, 0, *error, TBM_ERROR_INVALID_OPERATION);
+               TBM_RETURN_VAL_SET_ERR_IF_FAIL(bufmgr_func->bufmgr_get_capabilities, 0, *error, TBM_ERROR_NOT_SUPPORTED);
+
                capabilities = module->bufmgr_func->bufmgr_get_capabilities(module->bufmgr_data, error);
                break;
        case TBM_MODULE_TYPE_BUFMGR_BACKEND:
                TBM_WRN("!!WARNING: This backend interface will be DEPRECATED after Tizen 7.0.");
                TBM_ERR("Do not support at tbm_bufmgr_backend.");
+
                *error = TBM_ERROR_NOT_SUPPORTED;
                break;
        default: