The program below has a memory bug. Which statement correctly describes it?
#include <stdlib.h>
int main(void) {
char *buf = malloc(32);
buf = malloc(64);
free(buf);
return 0;
}
After the second assignment nothing points to the first block any more. Free it first, or use realloc() if you wanted a bigger buffer. LeakSanitizer or Valgrind would report "32 bytes definitely lost".