msi: Avoid a leak when a query is executed more than once.