mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Be careful with memory, some fixes for that.
This commit is contained in:
parent
004f5ccce6
commit
2af0d6f1a4
5 changed files with 11 additions and 5 deletions
|
@ -455,6 +455,7 @@ static void post_request_hook(ne_request *req, void *userdata, const ne_status *
|
|||
} else if( *sc_end == ';' ) {
|
||||
/* We are at the end of the session key. */
|
||||
int keylen = sc_end-sc_val;
|
||||
if( key ) SAFE_FREE(key);
|
||||
key = c_malloc(keylen+1);
|
||||
strncpy( key, sc_val, keylen );
|
||||
key[keylen] = '\0';
|
||||
|
|
|
@ -318,7 +318,7 @@ static int _insert_metadata_visitor(void *obj, void *data) {
|
|||
fs->mode,
|
||||
fs->modtime,
|
||||
fs->type,
|
||||
fs->md5);
|
||||
fs->md5 ? fs->md5 : "<empty>");
|
||||
|
||||
/*
|
||||
* The phash needs to be long long unsigned int or it segfaults on PPC
|
||||
|
|
|
@ -413,10 +413,15 @@ int csync_ftw(CSYNC *ctx, const char *uri, csync_walker_fn fn,
|
|||
}
|
||||
|
||||
if( ctx->current == LOCAL_REPLICA ) {
|
||||
char *md5 = NULL;
|
||||
int len = strlen( path );
|
||||
uint64_t h = c_jhash64((uint8_t *) path, len, 0);
|
||||
fs->md5 = csync_statedb_get_uniqId( ctx, h, fs );
|
||||
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_MD5;
|
||||
md5 = csync_statedb_get_uniqId( ctx, h, fs );
|
||||
if( md5 ) {
|
||||
SAFE_FREE(fs->md5);
|
||||
fs->md5 = md5;
|
||||
fs->fields |= CSYNC_VIO_FILE_STAT_FIELDS_MD5;
|
||||
}
|
||||
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "Uniq ID read from Database: %s -> %s", path, fs->md5 ? fs->md5 : "<NULL>" );
|
||||
}
|
||||
|
|
|
@ -230,7 +230,7 @@ static int _merge_file_trees_visitor(void *obj, void *data) {
|
|||
if( tfs && tfs->md5 ) {
|
||||
if( fs->md5 ) SAFE_FREE(fs->md5);
|
||||
fs->md5 = c_strdup( tfs->md5 );
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "PRE UPDATED %s: %s <-> %s", fs->path, fs->md5, tfs->md5);
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "PRE UPDATED %s: %s", fs->path, fs->md5);
|
||||
} else {
|
||||
CSYNC_LOG(CSYNC_LOG_PRIORITY_DEBUG, "md5 is empty in merger!");
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ csync_vio_file_stat_t *csync_vio_file_stat_new(void) {
|
|||
if (file_stat == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
file_stat->md5 = NULL;
|
||||
return file_stat;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue