diff options
author | Marcus Meissner <marcus@jet.franken.de> | 2020-07-26 10:41:41 +0200 |
---|---|---|
committer | Marcus Meissner <marcus@jet.franken.de> | 2020-07-26 10:41:41 +0200 |
commit | 7bc33498b1f2d701509ea30c1a0520bc4b9664ae (patch) | |
tree | ae73f78d257add8133c41f5eb534ec7a1bd497fe | |
parent | 1f4dc74a6ee5fd9823af705b2214a8c6f56db297 (diff) | |
download | libmtp-7bc33498b1f2d701509ea30c1a0520bc4b9664ae.tar.gz |
added some missing LIBMTP_destroy_file_t to avoid leaks.
fixes https://github.com/libmtp/libmtp/issues/52
-rw-r--r-- | src/libmtp.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libmtp.c b/src/libmtp.c index d6de0e4..4f2ec58 100644 --- a/src/libmtp.c +++ b/src/libmtp.c @@ -5286,6 +5286,7 @@ int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t *device, } if (mtpfile->filetype == LIBMTP_FILETYPE_FOLDER) { add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "LIBMTP_Get_File_To_File_Descriptor(): Bad object format."); + LIBMTP_destroy_file_t (mtpfile); return -1; } @@ -5353,6 +5354,7 @@ int LIBMTP_Get_File_To_Handler(LIBMTP_mtpdevice_t *device, } if (mtpfile->filetype == LIBMTP_FILETYPE_FOLDER) { add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "LIBMTP_Get_File_To_File_Descriptor(): Bad object format."); + LIBMTP_destroy_file_t (mtpfile); return -1; } @@ -9113,6 +9115,10 @@ int LIBMTP_GetPartialObject(LIBMTP_mtpdevice_t *device, uint32_t const id, if (offset + maxbytes > mtpfile->filesize) { maxbytes = mtpfile->filesize - offset; } + + /* do not need it anymore */ + LIBMTP_destroy_file_t (mtpfile); + /* The MTP stack of Samsung Galaxy devices has a mysterious bug in * GetPartialObject. When GetPartialObject is invoked to read the * last bytes of a file and the amount of data to read is such that |