Diagnose dangling aliases and double free

Assuming allocation success only for the diagnosis, draw the objects after each line of the broken fragment. Explain the use-after-free and double-free separately. Does owner = NULL change alias or restore the released block? Rewrite as a complete program that prints 5 exactly once and releases storage exactly once. Include allocation-failure handling. Do not run the invalid original or predict its output.

int *owner = malloc(2 * sizeof *owner);
int *alias = owner;
owner[0] = 5;
free(owner);
owner = NULL;
printf("%d\n", alias[0]);
free(alias);

