use g_strcmp0() instead of strcmp() to guard against corrupt settings in the config file

This commit is contained in:
Jordan Lee 2013-02-10 23:06:05 +00:00
parent b91014ba1e
commit 76a3b116f0
2 changed files with 11 additions and 12 deletions

View File

@ -216,9 +216,8 @@ gtr_actions_init (GtkUIManager * ui_manager, gpointer callback_user_data)
gtk_action_group_set_translation_domain (action_group, NULL);
match = gtr_pref_string_get (TR_KEY_sort_mode);
for (i = 0, n = G_N_ELEMENTS (sort_radio_entries), active = -1;
active == -1 && i < n; ++i)
if (!strcmp (sort_radio_entries[i].name, match))
for (i = 0, n = G_N_ELEMENTS (sort_radio_entries), active = -1; active == -1 && i < n; ++i)
if (!g_strcmp0 (sort_radio_entries[i].name, match))
active = i;
gtk_action_group_add_radio_actions (action_group,

View File

@ -23,7 +23,7 @@
*****************************************************************************/
#include <math.h> /* pow () */
#include <string.h> /* strcmp, strlen */
#include <string.h> /* strlen */
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@ -618,21 +618,21 @@ core_set_sort_mode (TrCore * core, const char * mode, gboolean is_reversed)
GtkSortType type = is_reversed ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING;
GtkTreeSortable * sortable = GTK_TREE_SORTABLE (gtr_core_model (core));
if (!strcmp (mode, "sort-by-activity"))
if (!g_strcmp0 (mode, "sort-by-activity"))
sort_func = compare_by_activity;
else if (!strcmp (mode, "sort-by-age"))
else if (!g_strcmp0 (mode, "sort-by-age"))
sort_func = compare_by_age;
else if (!strcmp (mode, "sort-by-progress"))
else if (!g_strcmp0 (mode, "sort-by-progress"))
sort_func = compare_by_progress;
else if (!strcmp (mode, "sort-by-queue"))
else if (!g_strcmp0 (mode, "sort-by-queue"))
sort_func = compare_by_queue;
else if (!strcmp (mode, "sort-by-time-left"))
else if (!g_strcmp0 (mode, "sort-by-time-left"))
sort_func = compare_by_eta;
else if (!strcmp (mode, "sort-by-ratio"))
else if (!g_strcmp0 (mode, "sort-by-ratio"))
sort_func = compare_by_ratio;
else if (!strcmp (mode, "sort-by-state"))
else if (!g_strcmp0 (mode, "sort-by-state"))
sort_func = compare_by_state;
else if (!strcmp (mode, "sort-by-size"))
else if (!g_strcmp0 (mode, "sort-by-size"))
sort_func = compare_by_size;
else {
sort_func = compare_by_name;