comparison libpurple/protocols/msn/contact.c @ 20489:321d25932f5e

Fix a bug where we were g_strdup'ing a previously freed pointer. Thanks to khc for the debugging.
author Carlos Silva <typ0@pidgin.im>
date Mon, 03 Sep 2007 20:32:57 +0000
parents ff4ae9dde291
children 82d8797e06f3
comparison
equal deleted inserted replaced
20488:64c322c3b1b0 20489:321d25932f5e
95 } 95 }
96 96
97 void 97 void
98 msn_callback_state_set_who(MsnCallbackState *state, const gchar *who) 98 msn_callback_state_set_who(MsnCallbackState *state, const gchar *who)
99 { 99 {
100 gchar *new_str = NULL;
101
100 g_return_if_fail(state != NULL); 102 g_return_if_fail(state != NULL);
103
104 if (who != NULL)
105 new_str = g_strdup(who);
101 106
102 if (state->who != NULL) 107 if (state->who != NULL)
103 g_free(state->who); 108 g_free(state->who);
104 109
105 state->who = who != NULL ? g_strdup(who) : NULL; 110 state->who = new_str;
106 } 111 }
107 112
108 void 113 void
109 msn_callback_state_set_old_group_name(MsnCallbackState *state, const gchar *old_group_name) 114 msn_callback_state_set_old_group_name(MsnCallbackState *state, const gchar *old_group_name)
110 { 115 {
116 gchar *new_str = NULL;
117
111 g_return_if_fail(state != NULL); 118 g_return_if_fail(state != NULL);
112 119
120 if (old_group_name != NULL)
121 new_str = g_strdup(old_group_name);
122
113 if (state->old_group_name != NULL) 123 if (state->old_group_name != NULL)
114 g_free(state->old_group_name); 124 g_free(state->old_group_name);
115 125
116 state->old_group_name = old_group_name != NULL ? g_strdup(old_group_name) : NULL; 126 state->old_group_name = new_str;
117 } 127 }
118 128
119 void 129 void
120 msn_callback_state_set_new_group_name(MsnCallbackState *state, const gchar *new_group_name) 130 msn_callback_state_set_new_group_name(MsnCallbackState *state, const gchar *new_group_name)
121 { 131 {
132 gchar *new_str = NULL;
133
122 g_return_if_fail(state != NULL); 134 g_return_if_fail(state != NULL);
123 135
136 if (new_group_name != NULL)
137 new_str = g_strdup(new_group_name);
138
124 if (state->new_group_name != NULL) 139 if (state->new_group_name != NULL)
125 g_free(state->new_group_name); 140 g_free(state->new_group_name);
126 141
127 state->new_group_name = new_group_name != NULL ? g_strdup(new_group_name) : NULL; 142 state->new_group_name = new_str;
128 } 143 }
129 144
130 void 145 void
131 msn_callback_state_set_guid(MsnCallbackState *state, const gchar *guid) 146 msn_callback_state_set_guid(MsnCallbackState *state, const gchar *guid)
132 { 147 {
148 gchar *new_str = NULL;
149
133 g_return_if_fail(state != NULL); 150 g_return_if_fail(state != NULL);
151
152 if (guid != NULL)
153 new_str = g_strdup(guid);
134 154
135 if (state->guid != NULL) 155 if (state->guid != NULL)
136 g_free(state->guid); 156 g_free(state->guid);
137 157
138 state->guid = guid != NULL ? g_strdup(guid) : NULL; 158 state->guid = new_str;
139 } 159 }
140 160
141 161
142 void 162 void
143 msn_callback_state_set_list_id(MsnCallbackState *state, MsnListId list_id) 163 msn_callback_state_set_list_id(MsnCallbackState *state, MsnListId list_id)