this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

app: bounds check printed messages slice

Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>

+3 -2
+3 -2
src/app.zig
··· 1143 1143 ) !void { 1144 1144 if (channel.messages.items.len == 0) return; 1145 1145 const client = channel.client; 1146 - const messages = channel.messages.items[0 .. channel.messages.items.len - self.state.messages.scroll_offset]; 1146 + const last_msg_idx = channel.messages.items.len -| self.state.messages.scroll_offset; 1147 + const messages = channel.messages.items[0..@max(1, last_msg_idx)]; 1147 1148 // We draw a gutter for time information 1148 1149 const gutter_width: usize = 6; 1149 1150 ··· 1172 1173 ); 1173 1174 1174 1175 // Define a few state variables for the loop 1175 - const last_msg = messages[messages.len - 1]; 1176 + const last_msg = messages[messages.len -| 1]; 1176 1177 1177 1178 // Initialize prev_time to the time of the last message, falling back to "now" 1178 1179 var prev_time: zeit.Instant = last_msg.localTime(&self.tz) orelse