From 9c41f98d70141296a629db8a3a8148d1fc5f94bb Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 29 Nov 2014 11:19:03 +0800 Subject: [PATCH] lda_controller: fix memory leak --- artiq/devices/lda/lda_controller.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/artiq/devices/lda/lda_controller.py b/artiq/devices/lda/lda_controller.py index 55fb3ab50..784172231 100755 --- a/artiq/devices/lda/lda_controller.py +++ b/artiq/devices/lda/lda_controller.py @@ -138,12 +138,13 @@ class Lda: def enumerate(cls, product): devs = hidapi.hid_enumerate(cls._vendor_id, cls._product_ids[product]) - dev = devs - while dev: - yield dev[0].serial - dev = dev[0].next - yield None - hidapi.hid_free_enumeration(devs) + try: + dev = devs + while dev: + yield dev[0].serial + dev = dev[0].next + finally: + hidapi.hid_free_enumeration(devs) def _check_error(self, ret): if ret < 0: