aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-02-28 16:40:16 -0300
committerdequis <dx@dxzone.com.ar>2015-02-28 17:40:07 -0300
commita880e34c6aeba0775875e3113ff84d6d46fd5d49 (patch)
treefd2d3eccfa84b8ecb39caa6d9850aa2038258dd4
parent8eb2e840353cbc669e4a566cf3a79408bcdb2b28 (diff)
Refactor oauth_params_del to fix use-after-free that i introduced
Yeah ok that was dumb. This is essentially just using a 'data' variable instead of 'l->data', but i went ahead and cleaned up the function.
-rw-r--r--lib/oauth.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/oauth.c b/lib/oauth.c
index ac5bc654..005d76c4 100644
--- a/lib/oauth.c
+++ b/lib/oauth.c
@@ -95,19 +95,18 @@ void oauth_params_add(GSList **params, const char *key, const char *value)
void oauth_params_del(GSList **params, const char *key)
{
int key_len = strlen(key);
- GSList *l, *n;
+ GSList *l;
- if (params == NULL) {
+ if (!params) {
return;
}
- for (l = *params; l; l = n) {
- n = l->next;
+ for (l = *params; l; l = l->next) {
+ char *data = l->data;
- if (strncmp((char *) l->data, key, key_len) == 0 &&
- ((char *) l->data)[key_len] == '=') {
- *params = g_slist_remove(*params, l->data);
- g_free(l->data);
+ if (strncmp(data, key, key_len) == 0 && data[key_len] == '=') {
+ *params = g_slist_remove(*params, data);
+ g_free(data);
}
}
}