Don't you also have to set `ctx->uuid` to `NULL` to assure pointer is false? Otherwise you could still be double freeing at some point?

> The free() function deallocates the memory allocation pointed to by ptr. If ptr is a NULL pointer, no operation is performed.

I am not sure you need those ifs around as well. Just free and set to NULL.