Public bug reported:

The following patch fixes the problem.  Cut and paste may have converted tabs 
to spaces (sorry).
I sent this to lists.debian.org as well, but not sure if that is the right 
place.
I am running Ubuntu 17.10 and package lists as bsdgames-2.17-25, but this fix 
was done in source listed as bsdgames-2,17-26build1, so that version is also 
broken.

*** hack.o_init.c.old   2003-12-16 20:47:37.000000000 -0600
--- hack.o_init.c       2018-03-25 20:35:59.362696144 -0600
***************
*** 184,191 ****
        bwrite(fd, (char *) bases, sizeof bases);
        bwrite(fd, (char *) objects, sizeof objects);
        /*
!        * as long as we use only one version of Hack/Quest we need not save
!        * oc_name and oc_descr, but we must save oc_uname for all objects
         */
        for (i = 0; i < SIZE(objects); i++) {
                if (objects[i].oc_uname) {
--- 184,190 ----
        bwrite(fd, (char *) bases, sizeof bases);
        bwrite(fd, (char *) objects, sizeof objects);
        /*
!        * Save oc_name, oc_descr, as well as oc_uname for all objects
         */
        for (i = 0; i < SIZE(objects); i++) {
                if (objects[i].oc_uname) {
***************
*** 193,198 ****
--- 192,207 ----
                        bwrite(fd, (char *) &len, sizeof len);
                        bwrite(fd, objects[i].oc_uname, len);
                }
+               if (objects[i].oc_name) {
+                       len = strlen(objects[i].oc_name) + 1;
+                       bwrite(fd, (char *) &len, sizeof len);
+                       bwrite(fd, objects[i].oc_name, len);
+               }
+               if (objects[i].oc_descr) {
+                       len = strlen(objects[i].oc_descr) + 1;
+                       bwrite(fd, (char *) &len, sizeof len);
+                       bwrite(fd, objects[i].oc_descr, len);
+               }
        }
  }
  
***************
*** 205,215 ****
--- 214,236 ----
        mread(fd, (char *) bases, sizeof bases);
        mread(fd, (char *) objects, sizeof objects);
        for (i = 0; i < SIZE(objects); i++)
+       {
                if (objects[i].oc_uname) {
                        mread(fd, (char *) &len, sizeof len);
                        objects[i].oc_uname = (char *) alloc(len);
                        mread(fd, objects[i].oc_uname, len);
                }
+               if (objects[i].oc_name) {
+                       mread(fd, (char *) &len, sizeof len);
+                       objects[i].oc_name = (char *) alloc(len);
+                       mread(fd, objects[i].oc_name, len);
+               }
+               if (objects[i].oc_descr) {
+                       mread(fd, (char *) &len, sizeof len);
+                       objects[i].oc_descr = (char *) alloc(len);
+                       mread(fd, objects[i].oc_descr, len);
+               }
+       }
  }
  
  int

** Affects: bsdgames (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1758805

Title:
  Program hack in bsdgames-2.17.25 core dumps when you enter 'i' after
  restoring a saved game

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bsdgames/+bug/1758805/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to