GTK/GTK3 UI: fix crash when a sync runs while no service is selected

Running a sync while the UI had no service selected caused a crash in
find_updated_source_progress() because the code dereferences the NULL
prog_data->data->current_service pointer. Affected both the GTK2 and
GTK3 UI.

Fix it by checking for NULL and not doing anything if NULL.
This commit is contained in:
Patrick Ohly 2013-09-30 15:14:44 +02:00
parent f9f6eda294
commit 5a0f5a9793
2 changed files with 4 additions and 4 deletions

View file

@ -2476,9 +2476,9 @@ find_updated_source_progress (const char *name,
SyncevoSourcePhase phase,
source_progress_data *prog_data)
{
GHashTable *configs = prog_data->data->current_service->source_configs;
GHashTable *configs = prog_data->data->current_service ? prog_data->data->current_service->source_configs : NULL;
source_config *config;
config = g_hash_table_lookup (configs, name);
config = configs ? g_hash_table_lookup (configs, name) : NULL;
if (config) {
if (phase != config->phase) {
config->phase = phase;

View file

@ -2444,9 +2444,9 @@ find_updated_source_progress (const char *name,
SyncevoSourcePhase phase,
source_progress_data *prog_data)
{
GHashTable *configs = prog_data->data->current_service->source_configs;
GHashTable *configs = prog_data->data->current_service ? prog_data->data->current_service->source_configs : NULL;
source_config *config;
config = g_hash_table_lookup (configs, name);
config = configs ? g_hash_table_lookup (configs, name) : NULL;
if (config) {
if (phase != config->phase) {
config->phase = phase;