Is it possible that realloc
fails, when the new size is smaller than the old size of the buffer? In this example the buffer is resized from 100 to 50 bytes.
#include <stdlib.h>
#include <stdio.h>
int main(int, char**)
{
void* b,* a;
a = malloc(100);
if(!a) return 1;
b = realloc(a, 50);
if(!b)
{
puts("Is this reachable?");
free(a);
return 1;
}
free(b);
return 0;
}