commit 55198a88d8490309f60f25b36b09ec8be9976f04 from: Stefan Sperling date: Mon Jul 16 16:00:51 2018 UTC fix tog crash with window resize and scrolling commit - ecb28ae0fb5fc4ab8a9c79cb6607c6fe2db50a90 commit + 55198a88d8490309f60f25b36b09ec8be9976f04 blob - 492ec5555d6c92bb2fdc90b5534f5d72884d3eb0 blob + 45a8fe04d48e1908069d942f6e70917321e90bf5 --- tog/tog.c +++ tog/tog.c @@ -495,19 +495,6 @@ draw_commits(struct commit_queue_entry **last, int ncommits, width; char *id_str, *header; wchar_t *wline; - - entry = first; - *selected = NULL; - ncommits = 0; - while (entry) { - if (++ncommits - 1 == selected_idx) { - *selected = entry; - break; - } - entry = TAILQ_NEXT(entry, entry); - } - if (*selected == NULL) - return got_error(GOT_ERR_RANGE); err = got_object_id_str(&id_str, (*selected)->id); if (err) @@ -716,8 +703,11 @@ show_log_view(struct got_object_id *start_id, struct g */ err = queue_commits(graph, &commits, head_id, LINES, 1, repo, in_repo_path); - if (err && err->code != GOT_ERR_ITER_COMPLETED) - goto done; + if (err) { + if (err->code != GOT_ERR_ITER_COMPLETED) + goto done; + err = NULL; + } /* * Find entry corresponding to the first commit to display. @@ -775,6 +765,8 @@ show_log_view(struct got_object_id *start_id, struct g switch (ch) { case ERR: if (errno) { + if (errno == EINTR) + break; err = got_error_from_errno(); goto done; } @@ -834,8 +826,10 @@ show_log_view(struct got_object_id *start_id, struct g break; } case KEY_RESIZE: - if (selected > LINES - 1) + if (selected > LINES - 2) selected = LINES - 2; + if (selected > commits.ncommits - 1) + selected = commits.ncommits - 1; break; case KEY_ENTER: case '\r':