Sure enough, he tricks the Genie into freeing them from the Cave of Wonders by wishing to escape, but not rubbing the lamp whilst doing it.
Aladdin being clueless about how to wish on the genie's lamp could easily be interpreted as him gauging for a loophole. Wringing his hands in dismay in the dark, Aladdin finds that he can summon up powerful jinn, or genies, by rubbing the ring. The magician thereupon shuts him inside the cave with the lamp and departs. Aladdin goes in and returns with the lamp but refuses to hand it over to the magician until he is safely out of the cave. Living in the fictional Arabian port city of Agrabah, Aladdin is in a struggle with Jafar, the Sultan’s Grand Vizier, for control of a magic lamp and its powerful Genie as he falls in love and uses his wishes to win the heart of the Sultan’s. Aladdin is the story of a “diamond in the rough” thief and street urchin.
Aladdin – Rubbing the remake lamp for big returns.