Skip to content

Commit aafbc80

Browse files
Daniel LangeDaniel Lange
Daniel Lange
authored and
Daniel Lange
committed
Merge branch 'infocoredump' of BenBE/htop
2 parents 1c31e21 + adedc80 commit aafbc80

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

InfoScreen.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,17 @@ void InfoScreen_addLine(InfoScreen* this, const char* line) {
7777
}
7878

7979
void InfoScreen_appendLine(InfoScreen* this, const char* line) {
80-
ListItem* last = (ListItem*)Vector_get(this->lines, Vector_size(this->lines) - 1);
81-
ListItem_append(last, line);
80+
if (!Vector_size(this->lines)) {
81+
InfoScreen_addLine(this, line);
82+
return;
83+
}
84+
85+
Object* last = Vector_get(this->lines, Vector_size(this->lines) - 1);
86+
ListItem_append((ListItem*)last, line);
8287
const char* incFilter = IncSet_filter(this->inc);
83-
if (incFilter && Panel_get(this->display, Panel_size(this->display) - 1) != (Object*)last && String_contains_i(line, incFilter, true)) {
84-
Panel_add(this->display, (Object*)last);
88+
Object* displayLast = Panel_size(this->display) ? Panel_get(this->display, Panel_size(this->display) - 1) : NULL;
89+
if (incFilter && displayLast != last && String_contains_i(line, incFilter, true)) {
90+
Panel_add(this->display, last);
8591
}
8692
}
8793

Vector.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ bool Vector_countEquals(const Vector* this, unsigned int expectedCount) {
8080
}
8181

8282
Object* Vector_get(const Vector* this, int idx) {
83-
assert(idx >= 0 && idx < this->items);
83+
assert(idx >= 0);
84+
assert(idx < this->arraySize);
85+
assert(idx < this->items);
8486
assert(this->array[idx]);
8587
assert(Object_isA(this->array[idx], this->type));
8688
return this->array[idx];

0 commit comments

Comments
 (0)