The development of cracks and solution cavities in carbonate reservoirs can notably reduce the rock’s mechanical properties, leading to a severe wellbore collapse problem during drilling operations. To clarify the influence of the characteristics of cracks and solution cavities on the wellbore stability in the Dengying Formation carbonate reservoir in the Gaoshiti–Moxi area of Sichuan, the mechanical properties of carbonate rock were analyzed. Then, the influences of the attitude and width of cracks, the size and quantity of solution cavities, and their connectivity on wellbore stability were studied using FLAC3D 6.00 numerical simulation software. Our results show the following: (1) The cracks and solution cavities in the Dengying Formation carbonate rock cause significant differences in the rock’s mechanical properties. (2) The equivalent drilling fluid density of collapse pressure (ρc) considering the effects of cracks and solution cavities is 6.4% higher than without these effects, which is in good accordance with engineering practice. Additionally, cracks play a more significant role than solution cavities in affecting the wellbore stability. (3) When the orientation of a crack is closer to the direction of maximum horizontal stress, and the dip angle and width of the crack increase, the stress and deformation at the intersection of the crack and wellbore gradually increase, and correspondingly, ρc also increases. (4) The stress and displacement of various points around the solution cavities gradually increase with the increases in diameter and quantity of solution cavities, and ρc also increases. (5) Compared with the situation where cracks and solution cavities are not interconnected, the stress disturbance area around the wellbore is larger, and ρc is greater when cracks and solution cavities are interconnected.