Fix memory calculation issue with ctx_correct.c