mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-26 23:28:14 +03:00
Fix memory leaks and some more multibyte conversoins.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
parent
6b3ac8c685
commit
13bb5ca2c3
2 changed files with 11 additions and 11 deletions
|
@ -170,9 +170,10 @@ int c_isdir(const char *path) {
|
|||
const mbchar_t *wpath = c_multibyte(path);
|
||||
|
||||
if (_tstat (wpath, &sb) == 0 && S_ISDIR(sb.st_mode)) {
|
||||
c_free_multibyte(wpath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
c_free_multibyte(wpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,11 +50,13 @@ csync_vio_method_handle_t *csync_vio_local_open(const char *durl, int flags, mod
|
|||
const mbchar_t *url = c_multibyte(durl);
|
||||
|
||||
if ((fd = _topen(url, flags, mode)) < 0) {
|
||||
c_free_multibyte(url);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = c_malloc(sizeof(fhandle_t));
|
||||
if (handle == NULL) {
|
||||
c_free_multibyte(url);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -72,11 +74,13 @@ csync_vio_method_handle_t *csync_vio_local_creat(const char *durl, mode_t mode)
|
|||
const mbchar_t *url = c_multibyte(durl);
|
||||
|
||||
if(( fd = _tcreat( url, mode)) < 0) {
|
||||
c_free_multibyte(url);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle = c_malloc(sizeof(fhandle_t));
|
||||
if (handle == NULL) {
|
||||
c_free_multibyte(url);
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -162,19 +166,18 @@ csync_vio_method_handle_t *csync_vio_local_opendir(const char *name) {
|
|||
const mbchar_t *dirname = c_multibyte(name);
|
||||
handle = c_malloc(sizeof(dhandle_t));
|
||||
if (handle == NULL) {
|
||||
c_free_multibyte(dirname);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
handle->dh = _topendir( dirname );
|
||||
if (handle->dh == NULL) {
|
||||
c_free_multibyte(dirname);
|
||||
SAFE_FREE(handle);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
handle->path = c_utf8(dirname);
|
||||
#else
|
||||
handle->path = c_strdup(dirname);
|
||||
#endif
|
||||
handle->path = c_strdup(name);
|
||||
c_free_multibyte(dirname);
|
||||
|
||||
return (csync_vio_method_handle_t *) handle;
|
||||
}
|
||||
|
@ -220,11 +223,7 @@ csync_vio_file_stat_t *csync_vio_local_readdir(csync_vio_method_handle_t *dhandl
|
|||
goto err;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
file_stat->name = c_utf8(dirent->d_name);
|
||||
#else
|
||||
file_stat->name = c_strdup(dirent->d_name);
|
||||
#endif
|
||||
file_stat->name = (char*) c_utf8(dirent->d_name);
|
||||
file_stat->fields = CSYNC_VIO_FILE_STAT_FIELDS_NONE;
|
||||
|
||||
#ifndef _WIN32
|
||||
|
|
Loading…
Reference in a new issue