Explanation : A) is wrong. We don’t need to cast the result as void * is automatically and safely promoted to any other pointer type in this case.
B) It is discarded for obvious reason.
C) is wrong, because dangling pointer is nothing but the pointer which is pointing existing memory (deallocated or deleted memory) which is not happening here.
D) is the answer. When you are calling malloc second time, new location is assigned to x and previous memory location is lost and now we don’t have no reference to that location resulting in memory leak.