Skip to content

Commit

Permalink
Fixed SEGFAULT in WebDav task sync + type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KiralyCraft committed Mar 11, 2024
1 parent fc67ac0 commit 9b289d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions network/cloud_sync/webdav.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static char *webdav_get_auth_header(const char *method, const char *url)

static void webdav_log_http_failure(const char *path, http_transfer_data_t *data)
{
int i;
size_t i;
RARCH_WARN("webdav failed: %s: HTTP %d\n", path, data->status);
for (i = 0; data->headers && i < data->headers->size; i++)
RARCH_WARN("%s\n", data->headers->elems[i].data);
Expand All @@ -469,7 +469,7 @@ static void webdav_stat_cb(retro_task_t *task, void *task_data, void *user_data,

if (data && data->status == 401 && data->headers && webdav_st->basic == true)
{
int i;
size_t i;
webdav_st->basic = false;
for (i = 0; i < data->headers->size; i++)
{
Expand Down
17 changes: 13 additions & 4 deletions tasks/task_cloudsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ static bool task_cloud_sync_should_ignore_file(const char *filename)
static void task_cloud_sync_manifest_append_dir(file_list_t *manifest,
const char *dir_fullpath, char *dir_name)
{
int i;
size_t i;
struct string_list *dir_list;
char dir_fullpath_slash[PATH_MAX_LENGTH];

Expand All @@ -273,6 +273,12 @@ static void task_cloud_sync_manifest_append_dir(file_list_t *manifest,

dir_list = dir_list_new(dir_fullpath_slash, NULL, false, true, true, true);

if (dir_list->size == 0)
{
string_list_free(dir_list);
return;
}

file_list_reserve(manifest, manifest->size + dir_list->size);
for (i = 0; i < dir_list->size; i++)
{
Expand Down Expand Up @@ -318,7 +324,7 @@ static struct string_list *task_cloud_sync_directory_map(void)
static void task_cloud_sync_build_current_manifest(task_cloud_sync_state_t *sync_state)
{
struct string_list *dirlist = task_cloud_sync_directory_map();
int i;
size_t i;

if (!(sync_state->current_manifest = (file_list_t *)calloc(1, sizeof(file_list_t))))
{
Expand Down Expand Up @@ -368,7 +374,10 @@ static void task_cloud_sync_update_progress(retro_task_t *task)
if (sync_state->current_manifest)
count += sync_state->current_manifest->size;

task_set_progress(task, (val * 100) / count);
if (count != 0)
task_set_progress(task, (val * 100) / count);
else
task_set_progress(task, 100);
}

static void task_cloud_sync_add_to_updated_manifest(task_cloud_sync_state_t *sync_state, const char *key, char *hash, bool server)
Expand Down Expand Up @@ -490,7 +499,7 @@ static void task_cloud_sync_fetch_server_file(task_cloud_sync_state_t *sync_stat
char directory[PATH_MAX_LENGTH];
char filename[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
int i;
size_t i;

/* we're just fetching a file the server has, we can update this now */
task_cloud_sync_add_to_updated_manifest(sync_state, key, CS_FILE_HASH(server_file), true);
Expand Down

0 comments on commit 9b289d4

Please sign in to comment.