Skip to content

Commit f642ee7

Browse files
Copilotkovidgoyal
andauthored
Guard entries!=NULL in comparison loop; fix load-all index to count-1
Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/8b314b99-cb92-4015-ab8e-89bb84994a97 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
1 parent ab59d38 commit f642ee7

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

kitty/options/to-c.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static inline void
180180
background_images(PyObject *src, Options *opts) {
181181
static unsigned generation = 0;
182182
size_t new_count = (PyTuple_Check(src) && PyTuple_GET_SIZE(src) > 0) ? (size_t)PyTuple_GET_SIZE(src) : 0;
183-
if (new_count == opts->background_images.count) {
183+
if (new_count == opts->background_images.count && opts->background_images.entries) {
184184
bool changed = false;
185185
for (size_t i = 0; i < new_count; i++) {
186186
const char *p = PyUnicode_AsUTF8(PyTuple_GET_ITEM(src, i));

kitty/state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ increment_bg_image_idx(size_t idx, int delta) {
275275
}
276276
if ((unsigned)abs(delta) <= idx) return idx + delta;
277277
// wrap to last image, which means we need to load all
278-
global_background_image(OPT(background_images).count);
278+
if (OPT(background_images).count > 0) global_background_image(OPT(background_images).count - 1);
279279
return global_state.background_images.count ? global_state.background_images.count - 1 : 0;
280280
}
281281

0 commit comments

Comments
 (0)