浏览代码

tsilo: fix internal data structures

- avoid crash by fixing "first" and "last" pointers of of the ts_entry_t after ts_urecord_t deletion
Vitaliy Aleksandrov 7 年之前
父节点
当前提交
cf26bbe333
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/modules/tsilo/ts_hash.c

+ 4 - 4
src/modules/tsilo/ts_hash.c

@@ -280,10 +280,10 @@ void remove_ts_urecord(ts_urecord_t* _r)
 	if (_r->next)
 	if (_r->next)
 		_r->next->prev = _r->prev;
 		_r->next->prev = _r->prev;
 
 
-	/* it was the last urecord */
-	if (entry->n == 1) {
-                entry->first = entry->last = NULL;
-	}
+	if (entry->first == _r)
+		entry->first = _r->next;
+	if (entry->last == _r)
+		entry->last = _r->prev;
 
 
 	update_stat(stored_ruris, -1);
 	update_stat(stored_ruris, -1);