How to free memory returned by ktxTexture_WriteToMemory()?

The documentation for this function says that:

Memory is allocated by the function and the caller is responsible for freeing it.
I tried calling free() on the returned memory and it caused an exception. What is the correct way to delete this memory block?