tbm_surface_internal: fix wrong last result when tbm_bo_map is failed
[platform/core/uifw/libtbm.git] / src / tbm_surface_internal.c
index c365f77..7b714ee 100644 (file)
@@ -1387,6 +1387,7 @@ tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
        tbm_bo bos[4];
        int planes_bo_idx[TBM_SURF_PLANE_MAX];
        int i, j;
+       tbm_error_e error;
 
        _tbm_surface_mutex_lock();
        _tbm_set_last_result(TBM_ERROR_NONE);
@@ -1422,9 +1423,11 @@ tbm_surface_internal_get_info(tbm_surface_h surface, int opt,
                for (i = 0; i < num_bos; i++) {
                        bo_handles[i] = tbm_bo_map(bos[i], TBM_DEVICE_CPU, opt);
                        if (bo_handles[i].ptr == NULL) {
+                               error = tbm_get_last_error();
                                for (j = 0; j < i; j++)
                                        tbm_bo_unmap(bos[j]);
 
+                               _tbm_set_last_result(error);
                                TBM_ERR("error: tbm_surface(%p) opt(%d) map(%d)\n", surface, opt, map);
                                return 0;
                        }