IP itself doesn’t guarantee to deliver data correctly. It leaves all data protection to the transport protocol. Both TCP and UDP have mechanisms that guarantee that the data they deliver to an application is correct.
Using the IP layer the correct destination of the packet is identified & delivered. The Transport layer protocols(TCP/UDP) check if the data delivered are correct using Check sum mechanism. However if the destination IP is not alive, the packet is hopped by decrementing the TTL (Time to leave) field and when it becomes zero, the packet is lost and undelivered. If the Transport layer is UDP the source doesn’t know of the failure in delivery of the packet.