Browse code

rls: avoid access to item after free

Daniel-Constantin Mierla authored on 31/07/2017 06:20:08
Showing 1 changed files
... ...
@@ -105,14 +105,13 @@ static inline list_entry_t *list_remove(str strng, list_entry_t *list)
105 105
 	{
106 106
 		if (strncmp(p->strng->s, strng.s, strng.len) == 0)
107 107
 		{
108
+			list = list->next;
108 109
 			pkg_free(p->strng->s);
109 110
 			pkg_free(p->strng);
110 111
 			pkg_free(p);
111
-			return list->next;
112
-		}
113
-		else
114
-		{
115
-			list_entry_t *p = list, *q;
112
+			return list;
113
+		} else {
114
+			list_entry_t *q;
116 115
 
117 116
 			while (p->next != NULL && (cmp = strncmp(p->next->strng->s, strng.s, strng.len)) < 0)
118 117
 				p = p->next;