Write down some of the bug owos that you have written here.

1) Pointer to array forgotten to initialize before malloc (assigned to NULL)

2)

some_struct * ptr = A;
array[1] = *A;

And then forgot to release the PTR…

3)

char * buffer = NULL;
size_t sz = 0;
while(getline(&buffer, &sz, file) > 0){
   ...
}

Then forget to release the buffer…

4) Assume that line is a string (such as “apple”).

line[2] = '\0';

then

strchr(line, 'e');

It returns NULL. Because now line is “ap”;

5)

int* array = malloc(5 * sizeof(*array));
for (int i = 0; i < 5; i++){
    free(array + i);
}

Repeatedly free memory.