Browse Source

various fixes (fd leaks, mem leaks). Thanks to Manfred Weichel

dvh-chacham15-master
DINH Viet Hoa 9 years ago
parent
commit
4a7daf9f4e
8 changed files with 16 additions and 11 deletions
  1. +3
    -0
      build-windows/libetpan-config.h
  2. +3
    -0
      src/driver/implementation/mh/mhdriver.c
  3. +0
    -1
      src/driver/implementation/mh/mhdriver_cached.c
  4. +6
    -2
      src/driver/tools/generic_cache.c
  5. +1
    -1
      src/low-level/imap/xlist.c
  6. +2
    -2
      src/low-level/mbox/mailmbox.c
  7. +1
    -1
      src/low-level/mh/mailmh.c
  8. +0
    -4
      tests/decrypt.c

+ 3
- 0
build-windows/libetpan-config.h View File

@ -41,6 +41,9 @@
# if !defined(uint16_t)
typedef UINT16 uint16_t;
# endif
# if !defined(int16_t)
typedef INT16 int16_t;
# endif
# if !defined(uint32_t)
typedef UINT32 uint32_t;
# endif


+ 3
- 0
src/driver/implementation/mh/mhdriver.c View File

@ -539,6 +539,7 @@ static int get_list_folders(struct mailmh_folder * folder, clist ** result)
default:
res = mhdriver_mh_error_to_mail_error(r);
free(new_filename);
goto free;
}
@ -557,6 +558,7 @@ static int get_list_folders(struct mailmh_folder * folder, clist ** result)
r = get_list_folders(subfolder, &list);
if (r != MAIL_NO_ERROR) {
free(new_filename);
res = MAIL_ERROR_MEMORY;
goto free;
}
@ -565,6 +567,7 @@ static int get_list_folders(struct mailmh_folder * folder, clist ** result)
* result = list;
free(new_filename);
return MAIL_NO_ERROR;
free:


+ 0
- 1
src/driver/implementation/mh/mhdriver_cached.c View File

@ -346,7 +346,6 @@ static int read_max_uid_value(mailsession * session)
r = mailimf_cache_int_read(mmapstr, &cur_token, &written_uid);
if (r != MAIL_NO_ERROR) {
fclose(f);
res = r;
goto free_mmapstr;
}


+ 6
- 2
src/driver/tools/generic_cache.c View File

@ -97,12 +97,16 @@ int generic_cache_store(char * filename, char * content, size_t length)
if (fd == -1)
return MAIL_ERROR_FILE;
if (ftruncate(fd, length) < 0)
if (ftruncate(fd, length) < 0) {
close(fd);
return MAIL_ERROR_FILE;
}
str = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (str == (char *)MAP_FAILED)
if (str == (char *)MAP_FAILED) {
close(fd);
return MAIL_ERROR_FILE;
}
memcpy(str, content, length);
msync(str, length, MS_SYNC);


+ 1
- 1
src/low-level/imap/xlist.c View File

@ -106,7 +106,7 @@ int mailimap_xlist(mailimap * session, const char * mb,
result_list = clist_new();
if (result_list == NULL) {
res = MAILIMAP_ERROR_MEMORY;
goto err;
goto free_response;
}
for(cur = clist_begin(session->imap_response_info->rsp_extension_list) ; cur != NULL ; cur = clist_next(cur)) {


+ 2
- 2
src/low-level/mbox/mailmbox.c View File

@ -1307,14 +1307,14 @@ static int copy_to_old_file(char * source_filename,
memcpy(dest, source, size);
munmap(dest, size);
close(source_fd);
close(dest_fd);
munmap(source, size);
close(source_fd);
return MAILMBOX_NO_ERROR;
close_dest:
close(source_fd);
close(dest_fd);
unmap_source:
munmap(source, size);
close_source:


+ 1
- 1
src/low-level/mh/mailmh.c View File

@ -603,7 +603,7 @@ static int mailmh_folder_alloc_msg(struct mailmh_folder * folder,
}
#endif /* WIN32 */
else if (errno == EXDEV) {
free(filename);
free(new_filename);
return MAILMH_ERROR_FOLDER;
}
else if (errno == EPERM) {


+ 0
- 4
tests/decrypt.c View File

@ -36,10 +36,6 @@ int get_content_of_file(char * filename, char ** p_content, size_t * p_length)
if (fd < 0)
goto free;
fd = open(filename, O_RDONLY);
if (fd < 0)
goto free;
nread = 0;
do
{


Loading…
Cancel
Save