From c6ff379264a7e91efcc5fa85785d491f72ba4169 Mon Sep 17 00:00:00 2001 From: Peter Hatina Date: Tue, 11 Jun 2013 22:10:47 +0200 Subject: [PATCH] fix free raw devices list when mount index exceeds attached devices count --- src/simple-mtpfs-mtp-device.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/simple-mtpfs-mtp-device.cpp b/src/simple-mtpfs-mtp-device.cpp index f1a5bfe..c633a21 100644 --- a/src/simple-mtpfs-mtp-device.cpp +++ b/src/simple-mtpfs-mtp-device.cpp @@ -59,8 +59,10 @@ bool MTPDevice::connect(int dev_no) LIBMTP_error_number_t err = LIBMTP_Detect_Raw_Devices( &raw_devices, &raw_devices_cnt); - if (dev_no > raw_devices_cnt) + if (dev_no > raw_devices_cnt) { + free(static_cast(raw_devices)); return false; + } if (err != LIBMTP_ERROR_NONE) { switch(err) {