Download raw body.
tog blame crashes on empty file
On Wed, Jan 20, 2021 at 05:17:39PM +0100, Christian Weisgerber wrote: > tog's blame view segfaults when invoked on a zero-length file. > That shouldn't happen. > > I'm less clear on what should happen. I guess the current code > tries to do nothing, but that might be confusing. An "empty" blame > view [0/0]? The code is really not set up for this now. Thanks, nice catch! The result of this patch is an "empty" blame view [1/0]. That should be good enough. diff d51387a0c213a0d133580b7cf37bca8f7e8569f3 /home/stsp/src/got blob - b39c45d7a3b0afb03d2aa58d8de523c49e7e800a file + tog/tog.c --- tog/tog.c +++ tog/tog.c @@ -4237,8 +4237,12 @@ run_blame(struct tog_view *view) } err = got_object_blob_dump_to_file(&blame->filesize, &blame->nlines, &blame->line_offsets, blame->f, blob); - if (err || blame->nlines == 0) + if (err) goto done; + if (blame->nlines == 0) { + s->blame_complete = 1; + goto done; + } /* Don't include \n at EOF in the blame line count. */ if (blame->line_offsets[blame->nlines - 1] == blame->filesize) @@ -4438,7 +4442,7 @@ show_blame_view(struct tog_view *view) struct tog_blame_view_state *s = &view->state.blame; int errcode; - if (s->blame.thread == NULL) { + if (s->blame.thread == NULL && !s->blame_complete) { errcode = pthread_create(&s->blame.thread, NULL, blame_thread, &s->blame.thread_args); if (errcode)
tog blame crashes on empty file