lda_controller: fix memory leak

This commit is contained in:
Sebastien Bourdeauducq 2014-11-29 11:19:03 +08:00
parent 26180e7905
commit 9c41f98d70

View File

@ -138,12 +138,13 @@ class Lda:
def enumerate(cls, product): def enumerate(cls, product):
devs = hidapi.hid_enumerate(cls._vendor_id, devs = hidapi.hid_enumerate(cls._vendor_id,
cls._product_ids[product]) cls._product_ids[product])
dev = devs try:
while dev: dev = devs
yield dev[0].serial while dev:
dev = dev[0].next yield dev[0].serial
yield None dev = dev[0].next
hidapi.hid_free_enumeration(devs) finally:
hidapi.hid_free_enumeration(devs)
def _check_error(self, ret): def _check_error(self, ret):
if ret < 0: if ret < 0: