What is the return type here

The problem with the code you shared previously is that you set idx to zero and use it to calculate the number of bytes (idx * sizeof(char)) that need to be allocated via pvPortMalloc, which is zero.

Calling pvPortMalloc, to allocate zero bytes results in implementation-defined behavior; it can either return NULL or undefined behavior depending upon the implementation.