summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSooChan Lim <sc1.lim@samsung.com>2018-10-29 15:57:28 +0900
committerSooChan Lim <sc1.lim@samsung.com>2018-10-29 15:57:28 +0900
commit7e4e986273730eddfef0242a9da9b0fd081753b9 (patch)
tree21ecc2bc4fb07242341501c03ebb62ed5ddab9b4
parent3388ed6367e3b8d2ff368a0e5efa24a5c9240e0f (diff)
downloadlibtbm-shm-7e4e986273730eddfef0242a9da9b0fd081753b9.tar.gz
libtbm-shm-7e4e986273730eddfef0242a9da9b0fd081753b9.tar.bz2
libtbm-shm-7e4e986273730eddfef0242a9da9b0fd081753b9.zip
check if the real_size is negative
Change-Id: I8296ac9ed31763c5ad00ec43754eb33913dd6a2a
-rw-r--r--src/tbm_bufmgr_shm.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/tbm_bufmgr_shm.c b/src/tbm_bufmgr_shm.c
index 3315b68..7de5bfb 100644
--- a/src/tbm_bufmgr_shm.c
+++ b/src/tbm_bufmgr_shm.c
@@ -668,6 +668,14 @@ tbm_shm_bufmgr_import_fd(tbm_backend_bufmgr_data *bufmgr_data, tbm_fd key, tbm_e
}
real_size = lseek(key, 0, SEEK_END);
+ if (real_size < 0) {
+ TBM_SHM_LOG("[libtbm-shm:%d] error %s:%d Fail to allocate the bo private\n", getpid(), __FUNCTION__, __LINE__);
+ free(bo_shm);
+ if (error)
+ *error = TBM_ERROR_INVALID_OPERATION;
+ return 0;
+ }
+
bo_shm->pBase = mmap(NULL, real_size,
PROT_READ | PROT_WRITE, MAP_SHARED, key, 0);
if (bo_shm->pBase == MAP_FAILED) {