commit a00719e9ec7fca4511eb77a8aee31bd098f52c68 from: Stefan Sperling date: Fri Jun 17 11:01:26 2022 UTC fix a segfault in tog diff The f1 tempfile must always be created. Even if the initial diff has no objects on the left side, the view can be switched to a different diff which does have objects on both sides. When that happened, tog crashed. (To reproduce: open tog in got.git, hit G, hit Enter, hit <) commit - dd6e31d7e33e64ea324b0afe932b3a509d7d963e commit + a00719e9ec7fca4511eb77a8aee31bd098f52c68 blob - 3a68d826936ce61d03cad367b5fbd52ed10c4298 blob + 8782d2289745425a1fdaecbd1edbcab6c230e7e6 --- tog/tog.c +++ tog/tog.c @@ -3830,11 +3830,6 @@ open_diff_view(struct tog_view *view, struct got_objec s->id1 = got_object_id_dup(id1); if (s->id1 == NULL) return got_error_from_errno("got_object_id_dup"); - s->f1 = got_opentemp(); - if (s->f1 == NULL) { - err = got_error_from_errno("got_opentemp"); - goto done; - } } else s->id1 = NULL; @@ -3844,6 +3839,12 @@ open_diff_view(struct tog_view *view, struct got_objec goto done; } + s->f1 = got_opentemp(); + if (s->f1 == NULL) { + err = got_error_from_errno("got_opentemp"); + goto done; + } + s->f2 = got_opentemp(); if (s->f2 == NULL) { err = got_error_from_errno("got_opentemp");