Work the handle/fab to ensure its not holding the catch in the opening position. Then place a round item like a screwdriver in the lock, to stimulate the door meeting the door catch on the back of the car. It should catch the screwdriver in the lock? But if it allows the screwdriver to come back out the lock it may need replacement, or a bit of WD40.
Not sure if this makes sense?