Avoid segfault for Alt-U undo when no more moves left.
authorDavid Griffith <dave@661.org>
Wed, 9 Oct 2019 18:54:19 +0000 (11:54 -0700)
committerDavid Griffith <dave@661.org>
Wed, 9 Oct 2019 18:54:19 +0000 (11:54 -0700)
src/common/fastmem.c

index 0bdb78f82b58575f860f0c549e09320013ff00ca..962792ff42912f92ed14c16fbe83b615a21a6f6a 100644 (file)
@@ -896,7 +896,7 @@ static void mem_undiff(zbyte *diff, long diff_length, zbyte *dest)
  */
 int restore_undo(void)
 {
-       long pc = curr_undo->pc;
+       long pc;
 
        /* undo feature unavailable */
        if (f_setup.undo_slots == 0)
@@ -906,6 +906,8 @@ int restore_undo(void)
        if (curr_undo == NULL)
                return 0;
 
+       pc = curr_undo->pc;
+
        /* undo possible */
        memmove(zmp, prev_zmp, z_header.dynamic_size);
        SET_PC(pc);