diff --git a/libteec/src/tee_client_api.c b/libteec/src/tee_client_api.c index 6d398ab9..bb1c8372 100644 --- a/libteec/src/tee_client_api.c +++ b/libteec/src/tee_client_api.c @@ -82,7 +82,8 @@ static void *teec_paged_aligned_alloc(size_t sz) size_t page_sz = sysconf(_SC_PAGESIZE); size_t aligned_sz = ((sz + page_sz - 1) / page_sz) * page_sz; - if (!posix_memalign(&p, page_sz, aligned_sz)) + /* aligned_sz will be null if MAX_SIZE was requested */ + if (aligned_sz && !posix_memalign(&p, page_sz, aligned_sz)) return p; return NULL;