fix free raw devices list when mount index exceeds attached devices count

This commit is contained in:
Peter Hatina 2013-06-11 22:10:47 +02:00
parent 60900a9d91
commit c6ff379264
1 changed files with 3 additions and 1 deletions

View File

@ -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<void*>(raw_devices));
return false;
}
if (err != LIBMTP_ERROR_NONE) {
switch(err) {