OP-TEE / optee_os

Trusted side of the TEE
Other
1.59k stars 1.07k forks source link

When i use for init TEE_BigInt *par0[NUM_PRIMES],it toast init failed. #6987

Closed hallowsman closed 3 months ago

hallowsman commented 3 months ago

When i use for init TEE_BigInt *par0[NUM_PRIMES],it toast init failed. below is my code,is it Right? What can i do?

int NUM_PRIMES=100; TEE_BigInt *par0[NUM_PRIMES]; // 逐个填充数组 for (size_t i = 0; i < NUM_PRIMES; i++) { size_t len_tee = TEE_BigIntSizeInU32(1024); // 计算 1024 位整数所需的 uint32_t 数组大小 size_t len = TEE_BigIntSizeInU32(1024);

    // 分配内存
    par0[i] = (TEE_BigInt *)TEE_Malloc(sizeof(len * sizeof(uint32_t), TEE_MALLOC_FILL_ZERO);

    if (par0[i] == NULL)

    {
        printf("success\n");
    }
    else
    {
        printf("failed\n");
    }

}

jforissier commented 3 months ago

Hi @hallowsman,

For malloc(), NULL is failure not success.