When I call realloc on a pointer to reduce its size what does it happen? For example, let's considering this:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int* a = malloc(4*sizeof(int));
a[0]= 1;
a[1]= 1;
a[2]= 1;
a[3]= 1;
int* temp = realloc(a, 3* sizeof(int));
if(!temp)
exit(1);
a = temp;
a[3] = 10;
return 0;
}
I expect that when I call a = realloc(a, 3* sizeof(int)); it will throw SIGSEGV, but it doesn't.