check that malloc/realloc succeed